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

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
  SHA1:
3
- metadata.gz: 4d1d5df4c8919a37eb792af9d130524cdda253a9
4
- data.tar.gz: 3cc9c72f77a477cc76c29d65105cae8a6020f129
3
+ metadata.gz: 2e211bd4bbfc0febec543643070ea59ef6465ae1
4
+ data.tar.gz: d3ad629f5d8d12a2845f0de13a5eeee0c06fa1cd
5
5
  SHA512:
6
- metadata.gz: e784f1521aabd6d3661fe4e4c1075ef7a6a1670143736d04606c0af694bbf5d7982307c65142fe59266635f73cde17c834cef3e9a40ad0d517fdb6a752a43d7e
7
- data.tar.gz: b7e18ef566433b932e461e51019103abc98fe7da7aadc3de8e829a6f5fffaefbd6c0ff0094334ec20ce7a52ba7a822eeb8462a1d3f806bed3d9a99bbf73b6078
6
+ metadata.gz: 2af5b10939713fc6c6e1f51d7f9309c20da0b4f32858fc91955038a1f9f0adfd32a18b494cbe70610ae266e5ff48412f7c9d4216b81d2e296001f09fefe738e1
7
+ data.tar.gz: 1e3499e9571018686f3f1b790a170e5fa51ba75d5b71be2d48491c5b59a69fe13156a1d8917c0b20fdee306c85c0541e5adf8f51884bbefb7d11b549f74d4b59
data/example_config.rb CHANGED
@@ -32,35 +32,33 @@ updater do
32
32
  reporting 'no'
33
33
  end
34
34
 
35
- sensor do
36
- platform :yr
37
- end
35
+ yr__sensor
36
+ # strictly equivalent to:
37
+ #sensor do
38
+ # platform :yr
39
+ #end
40
+
38
41
 
39
- sensor do
40
- platform :speedtest
42
+ speedtest__sensor do
41
43
  monitored_conditions %w(ping)
42
44
  #hour [0, 6, 12, 18]
43
45
  #minute 5
44
46
  end
45
47
 
46
- sensor do
47
- platform :darksky
48
+ darksky__sensor do
48
49
  api_key 'FAKE_KEY'
49
50
  end
50
51
 
51
- sensor 'Ping Stats' do
52
- platform :statistics
52
+ statistics__sensor 'Ping Stats' do
53
53
  entity_id 'sensor.speedtest_ping'
54
54
  end
55
55
 
56
- sensor do
57
- platform :waqi
56
+ waqi__sensor do
58
57
  locations %w(paris)
59
58
  stations ['place victor basch']
60
59
  end
61
60
 
62
- device_tracker do
63
- platform :nmap_tracker
61
+ nmap_tracker__device_tracker do
64
62
  hosts '192.168.0.0/24'
65
63
  home_interval 10
66
64
  interval_seconds 120
@@ -73,8 +71,7 @@ zone 'Criteo' do
73
71
  icon 'mdi:desktop-tower'
74
72
  end
75
73
 
76
- light do
77
- platform :limitlessled
74
+ limitless__light do
78
75
  bridges([
79
76
  { host: '192.168.0.110', groups: [{ number: 1, type: 'rgbw', name: 'Table à manger' }] }
80
77
  ])
@@ -51,14 +51,22 @@ module HomeAssistant
51
51
  end
52
52
 
53
53
  def method_missing(name, *args, &block)
54
- super unless args.one? || Component::EMPTY_CONF_ALLOWED.include?(name) || block_given?
54
+ klass_parts = name.to_s.split('__')
55
+ klass_name = klass_parts.pop.camel_case
56
+
57
+ platform = klass_parts.pop
58
+
59
+ super unless args.one? || # one arg means it's the name
60
+ Component::EMPTY_CONF_ALLOWED.include?(name) || # some components don't have configuration
61
+ block_given? || # some component don't have a name
62
+ platform # some component simply have a platform and no additional conf
55
63
 
56
- klass_name = name.to_s.camel_case
57
64
  unless DSL.const_defined?(klass_name)
58
65
  debug("No #{klass_name} class, defining dynamic class")
59
66
  DSL.const_set(klass_name, Class.new(Component) {})
60
67
  end
61
68
  element = DSL.const_get(klass_name).new(*args)
69
+ element.send(:platform, platform) if platform
62
70
  component_list << element
63
71
  element.instance_eval(&block) if block_given?
64
72
  element
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.13
4
+ version: 0.1.0.pre.alpha.pre.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grégoire Seux