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 +4 -4
- data/example_config.rb +25 -0
- data/lib/home_assistant/generator/dsl.rb +1 -0
- data/lib/home_assistant/generator/script.rb +72 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baadd2540e2747c3816151988e3d9dbd038b0e50
|
4
|
+
data.tar.gz: 97503866f0d2de25e8bd8ee7611b96a970c92361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -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.
|
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:
|