netatmo 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2acdebb6919008d5b9b76987ffec7b2285ca9231f10705bbd345a7ec7552a95
4
- data.tar.gz: 56fb133bacffe77f6b53d0318e9229cfe4ad6b5254f57977ba6ee4614e2fbf49
3
+ metadata.gz: b3ef266bbbacba6b1ff49e39751806a2a9fb53d311e514a78a27e9733c88e279
4
+ data.tar.gz: '08b52dceec23cbbad2fdcd1290e6afaeda3f28ddc1e2066835536c142773c059'
5
5
  SHA512:
6
- metadata.gz: 147a22967a1df8528185ecfc759872d25b5a59b95217bb129b54c6681afa5f200a3e8704e8f917bbad66c7ab740e6000497ea87a1d037f97f48a52f1db1b763a
7
- data.tar.gz: 3b10bf2687314dcd12833f786b816678f1a8ce08001495e15e71e1610085c5312205a5c45ba930c6bb88516f75dd4d644447adb53f493c11a426756ec4d4cfaa
6
+ metadata.gz: f61bc4b416a962fee5d797f09bec2a427b700b5e7e1634b12f4c15beed23ed5983bbb0e0ca251fca62a650235cdedd6e0c9f38098e0d45e4a6ae807e66d8a610
7
+ data.tar.gz: aff153b8ee47833d3f93e33be068c1c9e54575c9f9fbd2ec11b28adcc5c188c877026e177304695e2113c99e9c0e1d36b0083c96fd83681bf47370d1b941268b
@@ -2,13 +2,7 @@
2
2
 
3
3
  module Netatmo
4
4
  class Administrative
5
- attr_accessor :unit
6
- attr_accessor :windunit
7
- attr_accessor :pressureunit
8
- attr_accessor :lang
9
- attr_accessor :reg_locale
10
- attr_accessor :country
11
- attr_accessor :feel_like
5
+ attr_accessor :unit, :windunit, :pressureunit, :lang, :reg_locale, :country, :feel_like
12
6
 
13
7
  def initialize(data)
14
8
  self.unit = Netatmo::Util::Unit.value(data['unit'])
@@ -7,8 +7,7 @@ module Netatmo
7
7
  class BatteryStatus
8
8
  extend Forwardable
9
9
 
10
- attr_accessor :type
11
- attr_accessor :value
10
+ attr_accessor :type, :value
12
11
 
13
12
  class << self
14
13
  attr_accessor :status_values
@@ -7,6 +7,7 @@ module Netatmo
7
7
  class Client
8
8
  BASE_URL = 'https://api.netatmo.net'
9
9
  attr_accessor :access_token, :refresh_token, :expires_at
10
+
10
11
  Config = Struct.new(:client_id, :client_secret, :username, :password, :base_url)
11
12
 
12
13
  def initialize(&config_block)
@@ -69,9 +70,11 @@ module Netatmo
69
70
 
70
71
  # rubocop:disable Naming/AccessorMethodName
71
72
  def get_station_data
73
+ raise 'Unauthenticated' unless authenticate
74
+
72
75
  response = connection.get('/api/getstationsdata', access_token: @access_token)
73
76
 
74
- raise 'Unauthenticated' unless response.status == 200
77
+ raise 'Got unsuccessful response' unless response.status == 200
75
78
 
76
79
  Netatmo::Weather::StationData.new(JSON.parse(response.body)['body'])
77
80
  end
@@ -93,6 +96,7 @@ module Netatmo
93
96
  @access_token = data['access_token']
94
97
  @refresh_token = data['refresh_token']
95
98
  @expires_at = Time.now + data['expires_in']
99
+ puts "successfully stored new access_token: #{@access_token} - expires at #{@expires_at}"
96
100
  end
97
101
  end
98
102
  end
@@ -3,9 +3,7 @@
3
3
  module Netatmo
4
4
  module DashboardData
5
5
  class CO2
6
- attr_accessor :time
7
- attr_accessor :value
8
- attr_accessor :unit
6
+ attr_accessor :time, :value, :unit
9
7
 
10
8
  def initialize(data)
11
9
  self.time = Time.at(data['time_utc'])
@@ -7,9 +7,7 @@ module Netatmo
7
7
  class HealthIndex
8
8
  extend Forwardable
9
9
 
10
- attr_accessor :time
11
- attr_accessor :value
12
- attr_accessor :unit
10
+ attr_accessor :time, :value, :unit
13
11
 
14
12
  def initialize(data)
15
13
  self.time = Time.at(data['time_utc'])
@@ -3,9 +3,7 @@
3
3
  module Netatmo
4
4
  module DashboardData
5
5
  class Humidity
6
- attr_accessor :time
7
- attr_accessor :value
8
- attr_accessor :unit
6
+ attr_accessor :time, :value, :unit
9
7
 
10
8
  def initialize(data)
11
9
  self.time = Time.at(data['time_utc'])
@@ -3,9 +3,7 @@
3
3
  module Netatmo
4
4
  module DashboardData
5
5
  class Noise
6
- attr_accessor :time
7
- attr_accessor :value
8
- attr_accessor :unit
6
+ attr_accessor :time, :value, :unit
9
7
 
10
8
  def initialize(data)
11
9
  self.time = Time.at(data['time_utc'])
@@ -7,11 +7,7 @@ module Netatmo
7
7
  class Pressure
8
8
  extend Forwardable
9
9
 
10
- attr_accessor :time
11
- attr_accessor :value
12
- attr_accessor :absolute_pressure
13
- attr_accessor :trend
14
- attr_accessor :unit
10
+ attr_accessor :time, :value, :absolute_pressure, :trend, :unit
15
11
 
16
12
  def initialize(data)
17
13
  self.time = Time.at(data['time_utc'])
@@ -3,10 +3,7 @@
3
3
  module Netatmo
4
4
  module DashboardData
5
5
  class Rain
6
- attr_accessor :time
7
- attr_accessor :value
8
- attr_accessor :sum_rain_1
9
- attr_accessor :sum_rain_24
6
+ attr_accessor :time, :value, :sum_rain_1, :sum_rain_24
10
7
 
11
8
  def initialize(data)
12
9
  self.time = Time.at(data['time_utc'])
@@ -3,14 +3,7 @@
3
3
  module Netatmo
4
4
  module DashboardData
5
5
  class Temperature
6
- attr_accessor :time
7
- attr_accessor :value
8
- attr_accessor :min
9
- attr_accessor :max
10
- attr_accessor :min_date
11
- attr_accessor :max_date
12
- attr_accessor :trend
13
- attr_accessor :unit
6
+ attr_accessor :time, :value, :min, :max, :min_date, :max_date, :trend, :unit
14
7
 
15
8
  def initialize(data)
16
9
  self.time = Time.at(data['time_utc'])
@@ -3,15 +3,7 @@
3
3
  module Netatmo
4
4
  module DashboardData
5
5
  class Wind
6
- attr_accessor :time
7
- attr_accessor :wind_strength
8
- attr_accessor :max_wind_strength
9
- attr_accessor :max_wind_strength_date
10
- attr_accessor :wind_angle
11
- attr_accessor :gust_strength
12
- attr_accessor :gust_angle
13
- attr_accessor :wind_historic
14
- attr_accessor :unit
6
+ attr_accessor :time, :wind_strength, :max_wind_strength, :max_wind_strength_date, :wind_angle, :gust_strength, :gust_angle, :wind_historic, :unit
15
7
 
16
8
  def initialize(data)
17
9
  self.time = Time.at(data['time_utc'])
@@ -4,11 +4,7 @@ require 'geocoder'
4
4
 
5
5
  module Netatmo
6
6
  class Place
7
- attr_accessor :altitude
8
- attr_accessor :city
9
- attr_accessor :country
10
- attr_accessor :location
11
- attr_accessor :timezone
7
+ attr_accessor :altitude, :city, :country, :location, :timezone
12
8
 
13
9
  def initialize(data)
14
10
  self.altitude = data['altitude']
@@ -2,8 +2,7 @@
2
2
 
3
3
  module Netatmo
4
4
  class User
5
- attr_accessor :mail
6
- attr_accessor :administrative
5
+ attr_accessor :mail, :administrative
7
6
 
8
7
  def initialize(data)
9
8
  self.mail = data['mail']
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Netatmo
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -3,25 +3,8 @@
3
3
  module Netatmo
4
4
  module Weather
5
5
  class BaseStation < Device
6
- attr_accessor :cipher_id
7
- attr_accessor :date_setup
8
- attr_accessor :last_status_store
9
- attr_accessor :last_upgrade
10
- attr_accessor :co2_calibrating
11
- attr_accessor :station_name
12
- attr_accessor :friend_users
13
- attr_accessor :read_only
14
-
15
- attr_accessor :temperature
16
- attr_accessor :co2
17
- attr_accessor :humidity
18
- attr_accessor :noise
19
- attr_accessor :pressure
20
-
21
- attr_accessor :wifi_status
22
- attr_accessor :place
23
-
24
- attr_accessor :modules
6
+ attr_accessor :cipher_id, :date_setup, :last_status_store, :last_upgrade, :co2_calibrating, :station_name, :place,
7
+ :friend_users, :read_only, :temperature, :co2, :humidity, :noise, :pressure, :wifi_status, :modules
25
8
 
26
9
  # DeviceType: NAMain
27
10
  def initialize(data)
@@ -3,9 +3,7 @@
3
3
  module Netatmo
4
4
  module Weather
5
5
  class BatteryDevice < Device
6
- attr_accessor :battery_vp
7
- attr_accessor :battery_percent
8
- attr_accessor :battery_status
6
+ attr_accessor :battery_vp, :battery_percent, :battery_status
9
7
 
10
8
  def initialize(data)
11
9
  super(data)
@@ -7,18 +7,7 @@ module Netatmo
7
7
  class Device
8
8
  extend Forwardable
9
9
 
10
- attr_accessor :id
11
- attr_accessor :type
12
- attr_accessor :data_types
13
- attr_accessor :module_name
14
- attr_accessor :code
15
- attr_accessor :reachable
16
- attr_accessor :dashboard_data
17
- attr_accessor :firmware
18
- attr_accessor :last_setup
19
- attr_accessor :last_message
20
- attr_accessor :last_seen
21
- attr_accessor :rf_status
10
+ attr_accessor :id, :type, :data_types, :module_name, :code, :reachable, :dashboard_data, :firmware, :last_setup, :last_message, :last_seen, :rf_status
22
11
 
23
12
  def_delegators :type, :base_station?, :outdoor_module?, :wind_gauge?, :rain_gauge?, :indoor_module?, :health_coach?
24
13
 
@@ -110,6 +99,7 @@ module Netatmo
110
99
  d
111
100
  end
112
101
 
102
+ # REWORK
113
103
  def values
114
104
  h = {}
115
105
  h[:co2] = co2 if co2?
@@ -3,9 +3,7 @@
3
3
  module Netatmo
4
4
  module Weather
5
5
  class IndoorModule < BatteryDevice
6
- attr_accessor :temperature
7
- attr_accessor :co2
8
- attr_accessor :humidity
6
+ attr_accessor :temperature, :co2, :humidity
9
7
 
10
8
  # DeviceType: NAModule4
11
9
  def initialize(data)
@@ -3,9 +3,7 @@
3
3
  module Netatmo
4
4
  module Weather
5
5
  class OutdoorModule < BatteryDevice
6
- attr_accessor :temperature
7
- attr_accessor :humidity
8
- attr_accessor :pressure
6
+ attr_accessor :temperature, :humidity, :pressure
9
7
 
10
8
  # DeviceType: NAModule1
11
9
  def initialize(data)
@@ -3,8 +3,7 @@
3
3
  module Netatmo
4
4
  module Weather
5
5
  class StationData
6
- attr_accessor :user
7
- attr_accessor :devices
6
+ attr_accessor :user, :devices
8
7
 
9
8
  def initialize(response)
10
9
  self.devices = []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netatmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Roth
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-10 00:00:00.000000000 Z
11
+ date: 2020-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: easy_enum
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0.81'
159
+ version: '0.87'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0.81'
166
+ version: '0.87'
167
167
  description: Ruby Wrapper for the Netatmo HTTP API
168
168
  email:
169
169
  - marco.roth@intergga.ch