home_assistant-generator 0.1.0.pre.alpha.pre.12 → 0.1.0.pre.alpha.pre.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example_config.rb +62 -1
- data/lib/home_assistant/generator/component.rb +1 -1
- data/lib/home_assistant/generator/properties.rb +19 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d1d5df4c8919a37eb792af9d130524cdda253a9
|
4
|
+
data.tar.gz: 3cc9c72f77a477cc76c29d65105cae8a6020f129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e784f1521aabd6d3661fe4e4c1075ef7a6a1670143736d04606c0af694bbf5d7982307c65142fe59266635f73cde17c834cef3e9a40ad0d517fdb6a752a43d7e
|
7
|
+
data.tar.gz: b7e18ef566433b932e461e51019103abc98fe7da7aadc3de8e829a6f5fffaefbd6c0ff0094334ec20ce7a52ba7a822eeb8462a1d3f806bed3d9a99bbf73b6078
|
data/example_config.rb
CHANGED
@@ -13,12 +13,73 @@ media_player 'KoKodi' do
|
|
13
13
|
port 8080
|
14
14
|
end
|
15
15
|
|
16
|
-
sun
|
16
|
+
sun # Track sun position
|
17
|
+
discovery # Discover some devices automatically
|
18
|
+
frontend # Enable home-assistant front-end
|
19
|
+
conversation # Allow to issue voice commands from the frontend
|
20
|
+
zeroconf # Expose home-assistant over bonjour
|
17
21
|
|
18
22
|
recorder do
|
19
23
|
purge_days 14
|
20
24
|
end
|
21
25
|
|
26
|
+
logbook do
|
27
|
+
# sun moves too much, useless in the log
|
28
|
+
exclude(domains: %w(sun))
|
29
|
+
end
|
30
|
+
|
31
|
+
updater do
|
32
|
+
reporting 'no'
|
33
|
+
end
|
34
|
+
|
35
|
+
sensor do
|
36
|
+
platform :yr
|
37
|
+
end
|
38
|
+
|
39
|
+
sensor do
|
40
|
+
platform :speedtest
|
41
|
+
monitored_conditions %w(ping)
|
42
|
+
#hour [0, 6, 12, 18]
|
43
|
+
#minute 5
|
44
|
+
end
|
45
|
+
|
46
|
+
sensor do
|
47
|
+
platform :darksky
|
48
|
+
api_key 'FAKE_KEY'
|
49
|
+
end
|
50
|
+
|
51
|
+
sensor 'Ping Stats' do
|
52
|
+
platform :statistics
|
53
|
+
entity_id 'sensor.speedtest_ping'
|
54
|
+
end
|
55
|
+
|
56
|
+
sensor do
|
57
|
+
platform :waqi
|
58
|
+
locations %w(paris)
|
59
|
+
stations ['place victor basch']
|
60
|
+
end
|
61
|
+
|
62
|
+
device_tracker do
|
63
|
+
platform :nmap_tracker
|
64
|
+
hosts '192.168.0.0/24'
|
65
|
+
home_interval 10
|
66
|
+
interval_seconds 120
|
67
|
+
track_new_devices 'yes'
|
68
|
+
end
|
69
|
+
|
70
|
+
zone 'Criteo' do
|
71
|
+
longitude 2.331610
|
72
|
+
latitude 48.878887
|
73
|
+
icon 'mdi:desktop-tower'
|
74
|
+
end
|
75
|
+
|
76
|
+
light do
|
77
|
+
platform :limitlessled
|
78
|
+
bridges([
|
79
|
+
{ host: '192.168.0.110', groups: [{ number: 1, type: 'rgbw', name: 'Table à manger' }] }
|
80
|
+
])
|
81
|
+
end
|
82
|
+
|
22
83
|
automation 'Activate movie playing scene' do
|
23
84
|
# trigger.when('KoKodi').from(:paused).to(:playing)
|
24
85
|
|
@@ -4,7 +4,7 @@ module HomeAssistant
|
|
4
4
|
module Generator
|
5
5
|
# generic home-assistant component
|
6
6
|
class Component
|
7
|
-
EMPTY_CONF_ALLOWED = %i(sun history logbook).freeze
|
7
|
+
EMPTY_CONF_ALLOWED = %i(sun history logbook discovery frontend conversation zeroconf).freeze
|
8
8
|
|
9
9
|
prepend Properties
|
10
10
|
|
@@ -13,15 +13,24 @@ class Hash
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
class
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
class Object
|
17
|
+
def convert_to_hash
|
18
|
+
has_to_h = ->(x) { x.respond_to?(:to_h) }
|
19
|
+
case self
|
20
|
+
when String, Numeric, TrueClass, FalseClass
|
21
|
+
self
|
22
|
+
when Symbol
|
23
|
+
to_s
|
24
|
+
when Hash
|
25
|
+
keys.each_with_object({}) do |key, hash|
|
26
|
+
hash[key.to_s] = self[key].convert_to_hash
|
27
|
+
end
|
28
|
+
when Array # here we suppose array of scalar
|
29
|
+
map(&:convert_to_hash)
|
30
|
+
when has_to_h
|
31
|
+
to_h
|
32
|
+
else
|
33
|
+
raise "Can't convert #{inspect} to a hash"
|
25
34
|
end
|
26
35
|
end
|
27
36
|
end
|
@@ -38,23 +47,7 @@ module HomeAssistant
|
|
38
47
|
end
|
39
48
|
|
40
49
|
def to_h
|
41
|
-
|
42
|
-
properties.transform_values do |value|
|
43
|
-
case value
|
44
|
-
when String, Numeric, TrueClass, FalseClass
|
45
|
-
value
|
46
|
-
when Symbol
|
47
|
-
value.to_s
|
48
|
-
when Hash
|
49
|
-
Mash.new(value).to_h
|
50
|
-
when has_to_h
|
51
|
-
value.to_h
|
52
|
-
when Array
|
53
|
-
raise NotImplementedError, 'should be implemented for arrays as well!'
|
54
|
-
else
|
55
|
-
raise "Can't convert #{value.inspect} to a hash"
|
56
|
-
end
|
57
|
-
end
|
50
|
+
properties.convert_to_hash
|
58
51
|
end
|
59
52
|
end
|
60
53
|
end
|