home_assistant-generator 0.1.0.pre.alpha.pre.12 → 0.1.0.pre.alpha.pre.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb0ed7625bc552cdd4966be0ce5e54b4760a05c4
4
- data.tar.gz: eb05fbedd343a26d180f63c2619d75481000624e
3
+ metadata.gz: 4d1d5df4c8919a37eb792af9d130524cdda253a9
4
+ data.tar.gz: 3cc9c72f77a477cc76c29d65105cae8a6020f129
5
5
  SHA512:
6
- metadata.gz: fa944d0f48f706cd55232a88a5ebfecb7f32c0f52b4ed0c99a99179d629cfa93ff0c526967ca9b079a3e187ae5147534abce8a64d4af5bffa0ae7238ff38efb5
7
- data.tar.gz: 1b1d2a6afb2a0af9a1d4cb57c0039454285c5a3d087987da88ad5a95f3cb0349252e8e499177149ed6d9d4ff182a0e3309c1d9cc2c151add4eb402d9c8dfd001
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 Mash
17
- def to_h
18
- keys.each_with_object({}) do |key, hash|
19
- hash[key] = case self[key]
20
- when Mash
21
- self[key].to_h
22
- else
23
- self[key]
24
- end
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
- has_to_h = ->(x) { x.respond_to?(:to_h) }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: home_assistant-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha.pre.12
4
+ version: 0.1.0.pre.alpha.pre.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grégoire Seux