huebot 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/huebot +1 -1
- data/lib/huebot/cli/helpers.rb +10 -3
- data/lib/huebot/compiler/api_v1.rb +21 -2
- data/lib/huebot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 587a390d34c338db6aa2cd4d94944b051cf25f6c77b2db25f86ae996cb76b44a
|
4
|
+
data.tar.gz: 1a0d4d34b73caa8123cf1336e61ebed393b104c9aad82b8245f65d3356bab890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d24c93bd23b68ccc914d0bd7834deee41d90faa96be78ce68d10f53ebcf55978b47f06beb569d5ef48d3d7cfb10501672df99a1312931e052a67fea9fb235b
|
7
|
+
data.tar.gz: 3c0e33394c515e02212192229df35bde7d79a36bd20590edb40d89f5f751bccaa3432921413c7ff0762638d3804a1e06aaca3a13c835d006d8aaa3f78c62dd6e
|
data/bin/huebot
CHANGED
data/lib/huebot/cli/helpers.rb
CHANGED
@@ -60,8 +60,10 @@ module Huebot
|
|
60
60
|
Program::Src.new(src, path, version)
|
61
61
|
}
|
62
62
|
|
63
|
-
if options.read_stdin
|
63
|
+
if !$stdin.isatty or options.read_stdin
|
64
|
+
puts "Please enter your YAML Huebot program below, followed by Ctrl+d:" if options.read_stdin
|
64
65
|
src = YAML.load($stdin.read)
|
66
|
+
puts "Executing..." if options.read_stdin
|
65
67
|
version = (src.delete("version") || 1.0).to_f
|
66
68
|
sources << Program::Src.new(src, "STDIN", version)
|
67
69
|
end
|
@@ -141,10 +143,15 @@ module Huebot
|
|
141
143
|
huebot ls
|
142
144
|
|
143
145
|
Run program(s):
|
144
|
-
huebot run
|
146
|
+
huebot run prog1.yaml [prog2.yaml [prog3.yaml ...]] [options]
|
147
|
+
|
148
|
+
Run program from STDIN:
|
149
|
+
cat prog1.yaml | huebot run [options]
|
150
|
+
huebot run [options] < prog1.yaml
|
151
|
+
huebot run -i [options]
|
145
152
|
|
146
153
|
Validate programs and inputs:
|
147
|
-
huebot check
|
154
|
+
huebot check prog1.yaml [prog2.yaml [prog3.yaml ...]] [options]
|
148
155
|
|
149
156
|
Print the current state of the given lights and/or groups:
|
150
157
|
huebot get-state [options]
|
@@ -13,6 +13,10 @@ module Huebot
|
|
13
13
|
TIMER_KEYS = ["timer"].freeze
|
14
14
|
DEADLINE_KEYS = ["until"].freeze
|
15
15
|
HHMM = /\A[0-9]{2}:[0-9]{2}\Z/.freeze
|
16
|
+
PERCENT_CAPTURE = /\A([0-9]+)%\Z/.freeze
|
17
|
+
MIN_KELVIN = 2000
|
18
|
+
MAX_KELVIN = 6530
|
19
|
+
MAX_BRI = 254
|
16
20
|
|
17
21
|
def initialize(api_version)
|
18
22
|
@api_version = api_version
|
@@ -105,12 +109,27 @@ module Huebot
|
|
105
109
|
|
106
110
|
ctk = state.delete "ctk"
|
107
111
|
case ctk
|
108
|
-
when
|
112
|
+
when MIN_KELVIN..MAX_KELVIN
|
109
113
|
state["ct"] = (1_000_000 / ctk).round # https://en.wikipedia.org/wiki/Mired
|
110
114
|
when nil
|
111
115
|
# pass
|
112
116
|
else
|
113
|
-
errors << "'transition.state.ctk' must be an integer between
|
117
|
+
errors << "'transition.state.ctk' must be an integer between #{MIN_KELVIN} and #{MAX_KELVIN}"
|
118
|
+
end
|
119
|
+
|
120
|
+
case state["bri"]
|
121
|
+
when Integer, nil
|
122
|
+
# pass
|
123
|
+
when PERCENT_CAPTURE
|
124
|
+
n = $1.to_i
|
125
|
+
if n >= 0 and n <= 100
|
126
|
+
percent = n * 0.01
|
127
|
+
state["bri"] = (MAX_BRI * percent).round
|
128
|
+
else
|
129
|
+
errors << "'transition.state.bri' must be an integer or a percent between 0% and 100%"
|
130
|
+
end
|
131
|
+
else
|
132
|
+
errors << "'transition.state.bri' must be an integer or a percent between 0% and 100%"
|
114
133
|
end
|
115
134
|
|
116
135
|
state
|
data/lib/huebot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huebot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|