https://github.com/marcoroth/netatmo-ruby
Ruby gem to interact with the Netatmo REST API
https://github.com/marcoroth/netatmo-ruby
api hacktoberfest netatmo ruby weather wrapper
Last synced: 12 months ago
JSON representation
Ruby gem to interact with the Netatmo REST API
- Host: GitHub
- URL: https://github.com/marcoroth/netatmo-ruby
- Owner: marcoroth
- License: mit
- Created: 2019-05-02T01:10:20.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-02-20T07:21:16.000Z (about 2 years ago)
- Last Synced: 2025-05-04T20:46:34.120Z (12 months ago)
- Topics: api, hacktoberfest, netatmo, ruby, weather, wrapper
- Language: Ruby
- Homepage:
- Size: 79.1 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Netatmo
Ruby API Wrapper for the [Netatmo API](https://dev.netatmo.com/apidocumentation/).

## Installation
Add this line to your application's Gemfile:
```ruby
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.
```ruby
# 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 = 'user@email.address'
config.password = 'UserPassword'
end
```
### Endpoint `/getstationdata`
`get_station_data` Returns all weather stations you have read access to.
```ruby
station_data = client.get_station_data
# => # ...>
```
#### Devices
You can access the base stations in the `devices` array.
```ruby
station_data.devices
# => [
# #,
# #
# ]
```
```ruby
base_station = station_data.devices.first
# => #
```
#### Modules
All to this base station connected modules are accessible in the `modules` array.
```ruby
base_station.modules
# => [
# #,
# #,
# #,
# #
# ]
```
```ruby
outdoor = base_station.modules.first
# => #,
# @humidity=#,
# @temperature=#,
# @unit="°C">
# >
```
#### Data Types
You can ask the module if it provides certain data types.
```ruby
outdoor.temperature?
# => true
```
```ruby
outdoor.noise?
# => false
```
If the data type is supported you can access the values.
```ruby
outdoor.temperature
# => #, ...>
```
#### Values
If you want to get a hash of all the available data types on the module you use the `values` method.
```ruby
outdoor.values
# => {
# :humidity=>#,
# :temperature=>#