fritzbox-smarthome 0.7.0 → 0.8.0

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: c4ed289626e1d8c8cacccb9f89eed39178c5b11c781c99a649b3872521a3d0d4
4
- data.tar.gz: 02b35061da61c6f1084b87192eefe55cc83113526addf7caff584240256997f7
3
+ metadata.gz: 5ea6ed68d8e2192e09bcb904d927fe415b4a83174496f73f2afb57ce3836780f
4
+ data.tar.gz: 63944795b9c64f8a0389aa95bd234b2c42a37972580360c6722caf3b80166ece
5
5
  SHA512:
6
- metadata.gz: d2840a781e1717f8e9b11fa1a18929b316c930e57ee3b5e57a24574ad2f065c1b44fa3837e85dc0e88367ff1f402826d5210d8bbf2b9a9079b48dbe655a9d1e8
7
- data.tar.gz: 02f972de29e194f5c42f7671c3caddfdfe046951e0fd91095f4614412c5afb76a1861ed71211f89d0e44b52ff909dd79df4f7e93d558d50e9903d217ab0e8be4
6
+ metadata.gz: 36b9d64dbf43c0cb0003944d205da74d5ea3164837f81afb111bdd99660c8e9716ce5f1151fc22a8640f35770f4be51c28116e60801c90b6d718d5584776c782
7
+ data.tar.gz: 5b5a06172b88d899d0c226dcf040d327ecc18075fc1d893f38d83d04deae1a74564bbe2b3d5517896f1b59bc722deee20b46bd1166122de82ed0993cbdc060a2
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.0
1
+ 3.3.3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.8.0
4
+
5
+ * Use `ActiveModel::Attributes`
6
+ * Allow usage in Rails `7.1` and `7.2`
7
+ * Drop usage in Rails `< 7.0`
8
+
3
9
  ## v0.7.0
4
10
 
5
11
  * Measure HTTP request duration
@@ -20,8 +20,9 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency 'activesupport', '>= 5.1', '<= 7.1'
24
- spec.add_dependency 'activemodel', '>= 5.1', '<= 7.1'
23
+ spec.add_dependency 'activesupport', '>= 7.0', '<= 8'
24
+ spec.add_dependency 'activemodel', '>= 7.0', '<= 8'
25
+ spec.add_dependency 'csv', '~> 3.2' # For httparty to silence deprecation warning in ruby >= 3.3.0
25
26
  spec.add_dependency 'httparty', '~> 0.20'
26
27
  spec.add_dependency 'nori', '~> 2.6'
27
28
  spec.add_dependency 'nokogiri', '~> 1.13'
@@ -2,15 +2,15 @@ module Fritzbox
2
2
  module Smarthome
3
3
  class Actor < Resource
4
4
  include ActiveModel::Model
5
+ include ActiveModel::Attributes
5
6
 
6
- attr_accessor \
7
- :id,
8
- :type,
9
- :ain,
10
- :present,
11
- :name,
12
- :manufacturer,
13
- :group_members
7
+ attribute :id, :string
8
+ attribute :type #, :symbol
9
+ attribute :ain, :string
10
+ attribute :present, :string
11
+ attribute :name, :string
12
+ attribute :manufacturer, :string
13
+ attribute :group_members #, :string, array: true
14
14
 
15
15
  ResourceNotFound = Class.new(RuntimeError)
16
16
 
@@ -1,14 +1,12 @@
1
1
  module Fritzbox
2
2
  module Smarthome
3
3
  class Heater < Actor
4
-
5
- attr_accessor \
6
- :battery,
7
- :batterylow,
8
- :hkr_temp_is,
9
- :hkr_temp_set,
10
- :hkr_next_change_period,
11
- :hkr_next_change_temp
4
+ attribute :battery, :integer
5
+ attribute :batterylow, :integer
6
+ attribute :hkr_temp_is, :float
7
+ attribute :hkr_temp_set, :float
8
+ attribute :hkr_next_change_period, :time
9
+ attribute :hkr_next_change_temp, :float
12
10
 
13
11
  class << self
14
12
  def match?(data)
@@ -1,9 +1,6 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Fritzbox
4
2
  module Smarthome
5
3
  class Lightbulb < Actor
6
-
7
4
  include Properties::SimpleOnOff
8
5
 
9
6
  class << self
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Fritzbox
4
2
  module Smarthome
5
3
  class NullLogger < Logger
@@ -9,20 +9,20 @@ module Fritzbox
9
9
  extend ActiveSupport::Concern
10
10
 
11
11
  included do
12
- attr_accessor :simpleonoff_state
12
+ attribute :simpleonoff_state, :integer
13
13
  end
14
14
 
15
15
  module ClassMethods
16
16
  def new_from_api(data)
17
17
  instance = defined?(super) ? super : new
18
- instance.simpleonoff_state = data.dig('simpleonoff', 'state').to_i
18
+ instance.simpleonoff_state = data.dig('simpleonoff', 'state')
19
19
  instance
20
20
  end
21
21
  end
22
22
 
23
23
  # @return [Boolean]
24
24
  def active?
25
- simpleonoff_state.to_s == "1"
25
+ simpleonoff_state == 1
26
26
  end
27
27
 
28
28
  # Makes a request to the Fritzbox and set the current instance's active state.
@@ -43,10 +43,9 @@ module Fritzbox
43
43
  def toggle!
44
44
  raise ArgumentError, "Attribute `ain` is missing on #{inspect}" unless respond_to?(:ain)
45
45
  value = active? ? 0 : 1
46
- response =
47
- Fritzbox::Smarthome::Resource.get(command: 'setsimpleonoff', ain: ain, onoff: value)
46
+ response = Fritzbox::Smarthome::Resource.get(command: 'setsimpleonoff', ain: ain, onoff: value)
48
47
 
49
- response.ok? && @simpleonoff_state = value
48
+ response.ok? && self.simpleonoff_state = value
50
49
  end
51
50
  end
52
51
  end
@@ -1,10 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'fritzbox/smarthome/properties/simple_on_off'
4
2
 
5
3
  module Fritzbox
6
4
  module Smarthome
7
- module Properties
8
- end
5
+ module Properties; end
9
6
  end
10
7
  end
@@ -1,10 +1,8 @@
1
1
  module Fritzbox
2
2
  module Smarthome
3
3
  class SmokeDetector < Actor
4
-
5
- attr_accessor \
6
- :alert_state,
7
- :last_alert
4
+ attribute :alert_state, :integer
5
+ attribute :last_alert, :time
8
6
 
9
7
  class << self
10
8
  def match?(data)
@@ -1,19 +1,17 @@
1
1
  module Fritzbox
2
2
  module Smarthome
3
3
  class Switch < Actor
4
-
5
4
  include Properties::SimpleOnOff
6
5
 
7
- attr_accessor \
8
- :switch_state,
9
- :switch_mode,
10
- :switch_lock,
11
- :switch_devicelock,
12
- :powermeter_voltage,
13
- :powermeter_power,
14
- :powermeter_energy,
15
- :temperature_celsius,
16
- :temperature_offset
6
+ attribute :switch_state, :integer
7
+ attribute :switch_mode, :string
8
+ attribute :switch_lock, :integer
9
+ attribute :switch_devicelock, :integer
10
+ attribute :powermeter_voltage, :integer
11
+ attribute :powermeter_power, :integer
12
+ attribute :powermeter_energy, :integer
13
+ attribute :temperature_celsius, :integer
14
+ attribute :temperature_offset, :integer
17
15
 
18
16
  class << self
19
17
  def match?(data)
@@ -25,15 +23,15 @@ module Fritzbox
25
23
  super(data)
26
24
 
27
25
  assign_attributes(
28
- switch_state: data.dig('switch', 'state').to_i,
29
- switch_mode: data.dig('switch', 'mode').to_s,
30
- switch_lock: data.dig('switch', 'lock').to_i,
31
- switch_devicelock: data.dig('switch', 'devicelock').to_i,
32
- powermeter_voltage: data.dig('powermeter', 'voltage').to_i,
33
- powermeter_power: data.dig('powermeter', 'power').to_i,
34
- powermeter_energy: data.dig('powermeter', 'energy').to_i,
35
- temperature_celsius: data.dig('temperature', 'celsius').to_i,
36
- temperature_offset: data.dig('temperature', 'offset').to_i
26
+ switch_state: data.dig('switch', 'state'),
27
+ switch_mode: data.dig('switch', 'mode'),
28
+ switch_lock: data.dig('switch', 'lock'),
29
+ switch_devicelock: data.dig('switch', 'devicelock'),
30
+ powermeter_voltage: data.dig('powermeter', 'voltage'),
31
+ powermeter_power: data.dig('powermeter', 'power'),
32
+ powermeter_energy: data.dig('powermeter', 'energy'),
33
+ temperature_celsius: data.dig('temperature', 'celsius'),
34
+ temperature_offset: data.dig('temperature', 'offset')
37
35
  )
38
36
  end
39
37
  end
@@ -1,5 +1,5 @@
1
1
  module Fritzbox
2
2
  module Smarthome
3
- VERSION = '0.7.0'.freeze
3
+ VERSION = '0.8.0'.freeze
4
4
  end
5
5
  end
@@ -18,13 +18,13 @@ module Fritzbox
18
18
  module Smarthome
19
19
  class Configuration
20
20
  include ActiveModel::Model
21
+ include ActiveModel::Attributes
21
22
 
22
- attr_accessor \
23
- :endpoint, \
24
- :username, \
25
- :password,
26
- :verify_ssl,
27
- :logger
23
+ attribute :endpoint, :string
24
+ attribute :username, :string
25
+ attribute :password, :string
26
+ attribute :verify_ssl, :boolean
27
+ attribute :logger
28
28
  end
29
29
 
30
30
  @config = Configuration.new.tap do |defaults|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fritzbox-smarthome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaus Meyer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-28 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,40 +16,54 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.1'
19
+ version: '7.0'
20
20
  - - "<="
21
21
  - !ruby/object:Gem::Version
22
- version: '7.1'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '5.1'
29
+ version: '7.0'
30
30
  - - "<="
31
31
  - !ruby/object:Gem::Version
32
- version: '7.1'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activemodel
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '5.1'
39
+ version: '7.0'
40
40
  - - "<="
41
41
  - !ruby/object:Gem::Version
42
- version: '7.1'
42
+ version: '8'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '5.1'
49
+ version: '7.0'
50
50
  - - "<="
51
51
  - !ruby/object:Gem::Version
52
- version: '7.1'
52
+ version: '8'
53
+ - !ruby/object:Gem::Dependency
54
+ name: csv
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.2'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '3.2'
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: httparty
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -199,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
213
  - !ruby/object:Gem::Version
200
214
  version: '0'
201
215
  requirements: []
202
- rubygems_version: 3.4.1
216
+ rubygems_version: 3.5.11
203
217
  signing_key:
204
218
  specification_version: 4
205
219
  summary: Client library to interface with Smarthome features of your FritzBox