home_assistant-generator 0.1.0.pre.alpha.pre.17 → 0.1.0.pre.alpha.pre.18

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: 806d1f9f109909a0d7286afa0069791c6c9bc3c1
4
- data.tar.gz: fd89de7ce72f24750c376855e03a12db4c23de29
3
+ metadata.gz: baadd2540e2747c3816151988e3d9dbd038b0e50
4
+ data.tar.gz: 97503866f0d2de25e8bd8ee7611b96a970c92361
5
5
  SHA512:
6
- metadata.gz: ba29263376b1d1bd3362780c9c4b37f67f6bbb58eb2eacc2789ba94752abb7b4a7feedf7fc8864c68579bae7aed01816d76e31df476fd5643b5f286b8122a803
7
- data.tar.gz: 4c413de923dca17398ea28231d974d5bd488c1691d19a9b5c9acf901365dbfdb6e320295f1d2142e0af7f3a8f43d8168df4270d74d35e37627a53e068257aa83
6
+ metadata.gz: 17d5942a6b48ca5e359f64e040e179bfebc84c681f3b4b06ac86a371cfef0d8634e00304aed6d386a69717f1821f4dc4f896da9e32a73aeb4718757641088aa1
7
+ data.tar.gz: a2000fc607441df2bd2a50a5004d7370c8022103c6b497533e79d339e76ea081ee293ce9e1f93d646013659b125a9c9d17fba5846cb1063e7806166650d41f1f
data/example_config.rb CHANGED
@@ -113,6 +113,31 @@ shell_command do
113
113
  radio_swiss_classic '/var/lib/hass/play_radio_swiss_classic.sh'
114
114
  end
115
115
 
116
+ script 'Restart HA' do
117
+ restart_homeassistant
118
+ end
119
+
120
+ #script 'Heal Zwave' do
121
+ # heal_network(:zwave)
122
+ # soft_reset(:zwave)
123
+ #end
124
+ #
125
+ #script 'Shower on' do
126
+ # run(:classical_music_on_kodi)
127
+ # delay(5.seconds)
128
+ # turn_on_light('group.sdb_parents').with(brightness: 20)
129
+ # delay(5.seconds)
130
+ # turn_on_light('group.sdb_parents').with(brightness: 40)
131
+ #end
132
+ #
133
+ #script 'bedtime' do
134
+ # turn_on_light('table_a_manger').with(transition: 1, brightness: 10, color_name: 'white')
135
+ # turn_on_light('table_a_manger').with(transition: 10, brightness: 215, color_name: 'white')
136
+ # delay(10.seconds) # wait for previous pipeline to complete
137
+ # delay(60.seconds) # wait go to bed
138
+ # turn_off_light('table_a_manger').with(transition: 60)
139
+ #end
140
+
116
141
  automation 'Activate movie playing scene' do
117
142
  # trigger.when('KoKodi').from(:paused).to(:playing)
118
143
 
@@ -2,6 +2,7 @@ require 'yaml'
2
2
 
3
3
  require_relative 'component'
4
4
  require_relative 'plural'
5
+ require_relative 'script'
5
6
  require_relative 'automation'
6
7
 
7
8
  module CamelCase
@@ -0,0 +1,72 @@
1
+ require_relative 'component'
2
+
3
+ class Array
4
+ def ===(value)
5
+ # self is the pattern, value is the object we try to match
6
+ return false unless value.is_a?(Array) && size == value.size
7
+ zip(value).all? do |pattern, b|
8
+ (pattern === b).tap do |res|
9
+ puts "#{pattern.inspect} === #{b} => #{res}"
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ module HomeAssistant
16
+ module Generator
17
+ class DSL
18
+ class Script < Component
19
+
20
+ def name_property
21
+ :alias
22
+ end
23
+
24
+ def alias(value = nil)
25
+ if value
26
+ @alias = value
27
+ properties[id]['alias'] ||= value
28
+ end
29
+ @alias
30
+ end
31
+
32
+ def id
33
+ @alias.underscore.tap do |_id|
34
+ properties[_id] ||= {}
35
+ end
36
+ end
37
+
38
+ class SequenceAction
39
+ def initialize(k, v)
40
+ @k = k
41
+ @v = v
42
+ end
43
+
44
+ def convert_to_hash
45
+ { @k => @v }
46
+ end
47
+ end
48
+
49
+ def method_missing(name, *args, &block)
50
+ properties[id]['sequence'] ||= []
51
+ parts = name.to_s.split('_')
52
+
53
+ empty = -> (array) { array.is_a?(Array) && array.empty? }
54
+ one_el = -> (array) { array.is_a?(Array) && array.one? }
55
+
56
+ case [args, parts]
57
+ when [empty, one_el]
58
+ return super if parts.size.one?
59
+ when [empty, Array]
60
+ # there is ambiguity if parts has 3 elements
61
+ component = parts.pop
62
+ SequenceAction.new('service', "#{component}.#{parts.join('_')}")
63
+ else
64
+ raise 'Not implemented yet!'
65
+ end.tap do |el|
66
+ properties[id]['sequence'] << el if el.is_a?(SequenceAction)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ 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.17
4
+ version: 0.1.0.pre.alpha.pre.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grégoire Seux
@@ -105,6 +105,7 @@ files:
105
105
  - lib/home_assistant/generator/dsl.rb
106
106
  - lib/home_assistant/generator/plural.rb
107
107
  - lib/home_assistant/generator/properties.rb
108
+ - lib/home_assistant/generator/script.rb
108
109
  - lib/home_assistant/generator/version.rb
109
110
  homepage:
110
111
  licenses: