home_assistant-generator 0.1.0.pre.alpha.pre.14 → 0.1.0.pre.alpha.pre.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/example_config.rb +15 -0
- data/lib/home_assistant/generator/dsl.rb +4 -1
- data/lib/home_assistant/generator/switch.rb +41 -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: 452b5f5dc4d24b34822fcb5491116af049310a8c
|
4
|
+
data.tar.gz: cd716d2e04ce7b929e7b4311118bc5b59e572ba4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaff0ae8bbed70d50fc532dd14655a9ec9206c9e14fc5946585d56043d77fc52541b46930f78c18731a8dfbffc12c2d9f569659e16741d8bca806f4654353bed
|
7
|
+
data.tar.gz: fd4dda4cd6eb269069e011a71de7f948dd18098ad4ae7408ab1d9eeabd85ce2a47ee0d3fc7ceeae7d31d9c86b5ec1d9b0ef30cacf60e5dfe2dfe8e955222821e
|
data/.rubocop.yml
CHANGED
data/example_config.rb
CHANGED
@@ -77,6 +77,21 @@ limitless__light do
|
|
77
77
|
])
|
78
78
|
end
|
79
79
|
|
80
|
+
command_line__switch 'capodimonte_led' do
|
81
|
+
command_on 'sudo systemctl start raspberry_led'
|
82
|
+
command_off 'sudo systemctl stop raspberry_led'
|
83
|
+
command_state 'sudo systemctl is-active raspberry_led > /dev/null 2>&1'
|
84
|
+
end
|
85
|
+
|
86
|
+
command_line__switch 'nzbget_pause' do
|
87
|
+
command_on <<~EOH.split("\n").join(" && ")
|
88
|
+
curl -XPOST capodimonte/nzbget/jsonrpc -d '{"method": "pausepost"}'
|
89
|
+
curl -XPOST capodimonte/nzbget/jsonrpc -d '{"method": "pausedownload"}'
|
90
|
+
EOH
|
91
|
+
command_off %(curl -XPOST capodimonte/nzbget/jsonrpc -d '{"method": "scheduleresume", "params": [1]}')
|
92
|
+
command_state %(curl -s capodimonte/nzbget/jsonrpc -d '{"method": "status"}' |grep -q 'Paused" : true')
|
93
|
+
end
|
94
|
+
|
80
95
|
automation 'Activate movie playing scene' do
|
81
96
|
# trigger.when('KoKodi').from(:paused).to(:playing)
|
82
97
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
require_relative 'component'
|
4
|
+
require_relative 'switch'
|
4
5
|
require_relative 'automation'
|
5
6
|
|
6
7
|
module CamelCase
|
@@ -61,7 +62,9 @@ module HomeAssistant
|
|
61
62
|
block_given? || # some component don't have a name
|
62
63
|
platform # some component simply have a platform and no additional conf
|
63
64
|
|
64
|
-
|
65
|
+
if DSL.const_defined?(klass_name)
|
66
|
+
debug("Found #{klass_name} in DSL namespace, will use it")
|
67
|
+
else
|
65
68
|
debug("No #{klass_name} class, defining dynamic class")
|
66
69
|
DSL.const_set(klass_name, Class.new(Component) {})
|
67
70
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module HomeAssistant
|
2
|
+
module Generator
|
3
|
+
# using default Component class behavior would lead to write:
|
4
|
+
# command_line__switch do
|
5
|
+
# switches(capodimonte_led: {
|
6
|
+
# command_on: ...,
|
7
|
+
# commond_off: ...
|
8
|
+
# },
|
9
|
+
# nzbget_pause: {
|
10
|
+
# command_on: ...,
|
11
|
+
# commond_off: ...
|
12
|
+
# })
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# which is not very convenient
|
16
|
+
# it is easier to read the following code:
|
17
|
+
#
|
18
|
+
# command_line__switch 'capodimonte_led' do
|
19
|
+
# command_on '...'
|
20
|
+
# command_off '...'
|
21
|
+
# end
|
22
|
+
# command_line__switch 'nzbget' do
|
23
|
+
# command_on '...'
|
24
|
+
# command_off '...'
|
25
|
+
# end
|
26
|
+
class DSL
|
27
|
+
class Switch < Component
|
28
|
+
def name(value)
|
29
|
+
@switch_name = value
|
30
|
+
end
|
31
|
+
def platform(value)
|
32
|
+
@platform = value
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_h
|
36
|
+
{ 'platform' => @platform, 'switches' => { @switch_name => super } }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grégoire Seux
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/home_assistant/generator/component.rb
|
91
91
|
- lib/home_assistant/generator/dsl.rb
|
92
92
|
- lib/home_assistant/generator/properties.rb
|
93
|
+
- lib/home_assistant/generator/switch.rb
|
93
94
|
- lib/home_assistant/generator/version.rb
|
94
95
|
homepage:
|
95
96
|
licenses:
|