An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Netatmo

Ruby API Wrapper for the [Netatmo API](https://dev.netatmo.com/apidocumentation/).

![Build Status](https://github.com/marcoroth/netatmo-ruby/workflows/Build/badge.svg)

## 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=>#