• Stars
    star
    7
  • Rank 2,221,199 (Top 46 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby gem to interact with the Netatmo REST API

Netatmo

Ruby API Wrapper for the Netatmo API.

Build Status

Installation

Add this line to your application's Gemfile:

gem 'netatmo'

And then execute:

$ bundle

Or install it yourself as:

$ gem install netatmo

Usage

Environment variables

Name Description
NETATMO_CLIENT_ID Your app client_id
NETATMO_CLIENT_SECRET Your app client_secret
NETATMO_USERNAME User address email
NETATMO_PASSWORD User password

Creating a client

To create a Netatmo client you can either set the required environment variables or pass the credentials via a config block to the initialize method.

# if you configured the required ENV variables
client = Netatmo::Client.new

# or if you want to provide the required credentials
client = Netatmo::Client.new do |config|
  config.client_id = '10acb39bc818e5789'
  config.client_secret = '10dsfxyzbkzva'
  config.username = '[email protected]'
  config.password = 'UserPassword'
end

Endpoint /getstationdata

get_station_data Returns all weather stations you have read access to.

station_data = client.get_station_data
# => #<Netatmo::Weather::StationData @devices=[...] @user=#<Netatmo::User> ...>

Devices

You can access the base stations in the devices array.

station_data.devices

# => [
#      #<Netatmo::Weather::BaseStation @id="00:11:22:00:11:22", @modules=[...] ...>,
#      #<Netatmo::Weather::BaseStation @id="12:23:34:45:56:67", @modules=[...] ...>
#    ]
base_station = station_data.devices.first
# => #<Netatmo::Weather::BaseStation @id="00:11:22:00:11:22", @code="NAMain", @data_types=["Temperature", "CO2", "Humidity", "Noise", "Pressure"], @modules=[...]>

Modules

All to this base station connected modules are accessible in the modules array.

base_station.modules
# => [
#      #<Netatmo::Weather::OutdoorModule @code="NAModule1", @data_types=["Temperature", "Humidity"], ...>,
#      #<Netatmo::Weather::WindGauge @code="NAModule2", @data_types=["Wind"], ...>,
#      #<Netatmo::Weather::IndoorModule @code="NAModule4", @data_types=["Temperature", "CO2", "Humidity"], ...>,
#      #<Netatmo::Weather::RainGauge @code="NAModule3", @data_types=["Rain"], ...>
#    ]
outdoor = base_station.modules.first

# =>  #<Netatmo::Weather::OutdoorModule
#       @id="11:22:33:44:55:66",
#       @code="NAModule1",
#       @data_types=["Temperature", "Humidity"],
#       @module_name="Module",
#       @reachable=true,
#       @firmware=44,
#       @last_setup=2014-12-24 21:57:28 +0100,
#       @last_message=2020-02-11 10:49:33 +0100,
#       @last_seen=2020-02-11 10:49:27 +0100,
#       @rf_status=66,
#       @battery_vp=5440,
#       @battery_percent=77,
#       @battery_status=#<Netatmo::BatteryStatus::OutdoorBatteryStatus @value=5440>,
#       @humidity=#<Netatmo::DashboardData::Humidity @time=2020-02-11 10:48:36 +0100, @value=62.0, @unit="%">,
#       @temperature=#<Netatmo::DashboardData::Temperature @time=2020-02-11 10:48:36 +0100, @value=13.6, @min=7.6,
#       @max=13.6, @min_date=2020-02-11 07:12:25 +0100, @max_date=2020-02-11 10:48:36 +0100,
#       @trend=#<Netatmo::Util::TempTrend @value=1>,
#       @unit="Β°C">
#     >

Data Types

You can ask the module if it provides certain data types.

outdoor.temperature?
# => true
outdoor.noise?
# => false

If the data type is supported you can access the values.

outdoor.temperature
# => #<Netatmo::DashboardData::Temperature @value=13.6, @min=7.6, @max=13.6, @unit="Β°C", @time=2020-02-11 10:48:36 +0100, @trend=#<Netatmo::Util::TempTrend @value=1>, ...>

Values

If you want to get a hash of all the available data types on the module you use the values method.

outdoor.values
# => {
#      :humidity=>#<Netatmo::DashboardData::Humidity ...>,
#      :temperature=>#<Netatmo::DashboardData::Temperature ...
#    }

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/netatmo-ruby.

License

The gem is available as open source under the terms of the MIT License.

More Repositories

1

turbo_power

Power-pack for Turbo Streams
TypeScript
323
star
2

turbo_power-rails

Power-pack for Turbo Streams
Ruby
219
star
3

current.js

A tiny 🀏 library (only 410 B) that allows you to access current `<meta>` elements
TypeScript
159
star
4

stimulus-lsp

Intelligent Stimulus tooling for Visual Studio Code and Neovim
TypeScript
127
star
5

gem.sh

Beautiful documentation for any Ruby gem.
Ruby
95
star
6

hotwire.io

Community-driven documentation and resource Hub for Hotwire.
HTML
94
star
7

turbo-morph

Morph action for Turbo Streams
JavaScript
90
star
8

boxdrop

Dropbox Clone built with StimulusReflex
Ruby
76
star
9

formulus

Client-side HTML form validations based on the browser HTML Form Validation API
TypeScript
72
star
10

phlexing

Simple ERB to Phlex converter
Ruby
71
star
11

turbo-ruby

Turbo helpers without the requirement for Rails
Ruby
41
star
12

cable-streams

Extend Turbo Streams with Custom Turbo Stream Actions and CableReady operations
TypeScript
26
star
13

stimulus-parser

Statically analyze Stimulus controllers in your project.
TypeScript
25
star
14

rails7-stimulus-reflex-esbuild

Example StimulusReflex installation using Rails 7 and esbuild
Ruby
24
star
15

stimulus-render

[PoC] HTML rendering mechanism for Stimulus Controllers
TypeScript
18
star
16

type_fusion

Collaborative Ruby type sampling
Ruby
16
star
17

local-time

Modern fork of Basecamp's `local-time`
TypeScript
12
star
18

easy_enum

Turn any Ruby class in an easy to use enum.
Ruby
12
star
19

cable_ready.cr

[WIP] CableReady Crystal port
Crystal
10
star
20

dependabot-bump-together-action

GitHub Action to bump multiple dependencies with dependabot in a single pull request
Ruby
8
star
21

rubocop-stimulus_reflex

Code style checking for StimulusReflex
Ruby
8
star
22

railsbytes-cli

CLI to apply Railsbytes.com templates to your Rails application
Ruby
7
star
23

cable-streams-rails

Rails companion gem for the `cable-streams` NPM package
Ruby
6
star
24

ShortLook-WhatsApp

Show WhatsApp users' profile pictures in ShortLook when you receive a WhatsApp notification
Objective-C
5
star
25

rubocop-cable_ready

Code style checking for CableReady
Ruby
4
star
26

ShortLook-Bandsintown

Show Bandsintown artists' profile pictures in ShortLook when you receive a Bandsintown notification
Objective-C
4
star
27

shortlook-cli

ShortLook CLI for scaffoling a ShortLook Provider
Ruby
3
star
28

stimulus-blurhash

Stimulus Controller for BlurHash
JavaScript
2
star
29

ShortLook-RocketChat

Show RocketChat users' profile pictures in ShortLook when you receive a RocketChat notification
Objective-C
2
star
30

ShortLook-VK

Show VK users' profile pictures in ShortLook when you receive a VK notification
Objective-C
2
star
31

ShortLook-GitHub

Show GitHub users' profile pictures in ShortLook when you receive a GitHub notification
Objective-C
2
star
32

ShortLook-Line

Show Line users' profile pictures in ShortLook when you receive a Line notification
Objective-C
2
star
33

ShortLook-KakaoTalk

Show KakaoTalk Contact Photos in ShortLook when you receive a KakaoTalk notification
Objective-C
2
star
34

usersnap-stimulus-repro

HTML
1
star
35

rcrdshp-market-extension

Small extension for the RCRDSHP Marketplace
JavaScript
1
star
36

POC2u

Ruby
1
star
37

cable_ready-dsl

[PoC] An opinionated DSL for CableReady.
Ruby
1
star
38

spritpreisrechner-ruby

Ruby Wrapper for the e-control.at Spritpreisrechner HTTP API
Ruby
1
star
39

tankerkoenig-ruby

Ruby Wrapper for the Tankerkoenig API
Ruby
1
star
40

async-websocket-with-inactive-tab

HTML
1
star
41

ShortLook-Mixcloud

Show Mixcloud covers in ShortLook when you receive a Mixcloud notification
Objective-C
1
star
42

stimulus_reflex-form-serialize-app

Ruby
1
star
43

mirrOS_spotify

Modul zum Anzeigen des zurzeit spielenden Track auf Spotify.
PHP
1
star
44

openmensa-parsers

OpenMensa.org parsers
Ruby
1
star
45

ShortLook-LinkedIn

Show LinkedIn users' profile pictures in ShortLook when you receive a LinkedIn notification
Objective-C
1
star
46

ShortLook-Slack

Show Slack users' profile pictures in ShortLook when you receive a Slack notification
Objective-C
1
star
47

ShortLook-SteamChat

Show SteamChat Profile Pictures in ShortLook when you receive a SteamChat notification!
Objective-C
1
star
48

ShortLook-Xing

Show Xing users' profile pictures in ShortLook when you receive a Xing notification
Objective-C
1
star
49

ShortLook-Viber

Show Viber users' profile pictures in ShortLook when you receive a Viber notification
Objective-C
1
star
50

mirrOS_todoist

Dieses mirrOS Modul zeigt deine Aufgaben aus einer Todoist-Liste an.
PHP
1
star