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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5da1b1dcd0f32ce09e44155b39d7bc6ed92aa285944fc3a67801cf02642737c0
4
- data.tar.gz: 9116d3a891e608276e64517f9252a42cddd615ca9952c55e816ca53196bdde15
3
+ metadata.gz: 587a390d34c338db6aa2cd4d94944b051cf25f6c77b2db25f86ae996cb76b44a
4
+ data.tar.gz: 1a0d4d34b73caa8123cf1336e61ebed393b104c9aad82b8245f65d3356bab890
5
5
  SHA512:
6
- metadata.gz: fc1ae1f775c685e635fe36d85ef33548a50163f80378f42301f73e9bdf868343fecb4b9a9fa64490466771dc44b51f95745587bc32423e65cdc306dae0e01fa9
7
- data.tar.gz: b5721fb115fc0f8c38e9389063a9012a51d7aa2fa0cf2f1b7a2d93812d916b2ffb1f27508358483a9656b4bdb09d7f78fc7bd9e4f65ff599214c9cdd2f0e8a93
6
+ metadata.gz: 40d24c93bd23b68ccc914d0bd7834deee41d90faa96be78ce68d10f53ebcf55978b47f06beb569d5ef48d3d7cfb10501672df99a1312931e052a67fea9fb235b
7
+ data.tar.gz: 3c0e33394c515e02212192229df35bde7d79a36bd20590edb40d89f5f751bccaa3432921413c7ff0762638d3804a1e06aaca3a13c835d006d8aaa3f78c62dd6e
data/bin/huebot CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # Used for local testing
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') if ENV["HUEBOT_DEV"] == "1"
5
5
 
6
6
  require 'huebot'
7
7
 
@@ -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 file1.yml [file2.yml [file3.yml ...]] [options]
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 file1.yml [file2.yml [file3.yml ...]] [options]
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 2000..6530
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 2700 and 6530"
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
@@ -1,4 +1,4 @@
1
1
  module Huebot
2
2
  # Gem version
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
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.0.0
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-18 00:00:00.000000000 Z
11
+ date: 2023-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest