fritzbox-smarthome 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/fritzbox/smarthome/actor.rb +1 -1
- data/lib/fritzbox/smarthome/lightbulb.rb +36 -0
- data/lib/fritzbox/smarthome/null_logger.rb +11 -0
- data/lib/fritzbox/smarthome/resource.rb +8 -1
- data/lib/fritzbox/smarthome/version.rb +1 -1
- data/lib/fritzbox/smarthome.rb +3 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 430136a0736fded1a9e2cf308cdeb00129e94514259915306146fc65be4fb04a
|
4
|
+
data.tar.gz: 8755e3f921c2c815b1e6d38d3372bcfff068e6a8aa7a47785d07213585e67101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94ac858e01f25649f9171df8cf685658b4a4e17f5c230a1394569c37d3052444ed1b155d8eb9a58d61fc056eb471347ee5c0c163b0a777651a8abceac4a3c76a
|
7
|
+
data.tar.gz: 198756b6e8a1d7d2cfcf886e26f5e2efd3d75eb655d2533e94074c936b42da531d58147ceba13e3a54b5e621f66fe99f56fe5652cbdd6c2b64294a095fa5e22e
|
data/CHANGELOG.md
CHANGED
@@ -29,7 +29,7 @@ module Fritzbox
|
|
29
29
|
ain: data.dig('@identifier').to_s,
|
30
30
|
present: data.dig('present') == '1',
|
31
31
|
name: (data.dig('name') || data.dig('@productname')).to_s,
|
32
|
-
manufacturer: data.dig('manufacturer').to_s,
|
32
|
+
manufacturer: (data.dig('manufacturer') || data.dig('@manufacturer')).to_s,
|
33
33
|
group_members: data.dig('groupinfo', 'members').to_s.split(',').presence
|
34
34
|
)
|
35
35
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Fritzbox
|
4
|
+
module Smarthome
|
5
|
+
class Lightbulb < Actor
|
6
|
+
|
7
|
+
attr_accessor \
|
8
|
+
:simpleonoff_state
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def match?(data)
|
12
|
+
data.fetch('@productname', '') =~ /FRITZ!DECT 5\d{2}/i
|
13
|
+
end
|
14
|
+
|
15
|
+
def new_from_api(data)
|
16
|
+
instance = super
|
17
|
+
instance.assign_attributes(
|
18
|
+
simpleonoff_state: data.dig('simpleonoff', 'state').to_i,
|
19
|
+
)
|
20
|
+
instance
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def active?
|
25
|
+
simpleonoff_state == 1
|
26
|
+
end
|
27
|
+
|
28
|
+
def toggle!
|
29
|
+
value = active? ? 0 : 1
|
30
|
+
response = self.class.get(command: 'setsimpleonoff', ain: ain, onoff: value)
|
31
|
+
|
32
|
+
response.ok? && @simpleonoff_state = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -2,11 +2,18 @@ module Fritzbox
|
|
2
2
|
module Smarthome
|
3
3
|
class Resource
|
4
4
|
class << self
|
5
|
-
|
5
|
+
# @param params [Hash] key/value pairs that will be appended to the switchcmd query string
|
6
|
+
def get(command:, ain: nil, param: nil, **params)
|
6
7
|
url = "#{config.endpoint}/webservices/homeautoswitch.lua?switchcmd=#{command}&sid=#{authenticate}"
|
7
8
|
url = "#{url}&ain=#{ain}" if ain.present?
|
8
9
|
url = "#{url}¶m=#{param}" if param.present?
|
9
10
|
|
11
|
+
params.each_with_object(url) do |(key, value)|
|
12
|
+
url = "#{url}&#{key}=#{value}"
|
13
|
+
end
|
14
|
+
|
15
|
+
config.logger.debug(url)
|
16
|
+
|
10
17
|
HTTParty.get(url, **httparty_options)
|
11
18
|
end
|
12
19
|
|
data/lib/fritzbox/smarthome.rb
CHANGED
@@ -4,11 +4,13 @@ require 'httparty'
|
|
4
4
|
require 'nori'
|
5
5
|
|
6
6
|
require 'fritzbox/smarthome/version'
|
7
|
+
require 'fritzbox/smarthome/null_logger'
|
7
8
|
require 'fritzbox/smarthome/resource'
|
8
9
|
require 'fritzbox/smarthome/actor'
|
9
10
|
require 'fritzbox/smarthome/heater'
|
10
11
|
require 'fritzbox/smarthome/switch'
|
11
12
|
require 'fritzbox/smarthome/smoke_detector'
|
13
|
+
require 'fritzbox/smarthome/lightbulb'
|
12
14
|
|
13
15
|
module Fritzbox
|
14
16
|
module Smarthome
|
@@ -28,7 +30,7 @@ module Fritzbox
|
|
28
30
|
defaults.username = 'smarthome'
|
29
31
|
defaults.password = 'verysmart'
|
30
32
|
defaults.verify_ssl = true
|
31
|
-
defaults.logger =
|
33
|
+
defaults.logger = NullLogger.new
|
32
34
|
end
|
33
35
|
|
34
36
|
class << self
|
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.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2022-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -171,6 +171,8 @@ files:
|
|
171
171
|
- lib/fritzbox/smarthome.rb
|
172
172
|
- lib/fritzbox/smarthome/actor.rb
|
173
173
|
- lib/fritzbox/smarthome/heater.rb
|
174
|
+
- lib/fritzbox/smarthome/lightbulb.rb
|
175
|
+
- lib/fritzbox/smarthome/null_logger.rb
|
174
176
|
- lib/fritzbox/smarthome/resource.rb
|
175
177
|
- lib/fritzbox/smarthome/smoke_detector.rb
|
176
178
|
- lib/fritzbox/smarthome/switch.rb
|