alexa_hue 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/alexa_hue/hue/voice_parser.rb +4 -6
- data/lib/alexa_hue/version.rb +1 -1
- data/lib/alexa_hue.rb +3 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40a90ef5b2445e359556fa8742c82678c9e22e7f
|
4
|
+
data.tar.gz: d6f773a6d0cf794281feb524b8c3dea86de639a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17e7d69e7cad79bc308d760a12dcb8b9f8e2ff0c4090299fb5df44440ce66d8a4665db64d9bc72f94650f9401bb824278faa90a13f6d8e6d77d0d6e8a637b272
|
7
|
+
data.tar.gz: 7131a59f1d835c6d2fcb48afaea11e0243b1c047c8c0a834ead80693fe7d9fa2af7c2f9a0eac1fa4ac11e2a2dde9c4fa48d5e1a13f79c08fadc6e6ee2236c72b
|
@@ -13,23 +13,21 @@ module Hue
|
|
13
13
|
@client = options[:js] ? Hue::JsClient.new(options[:js]) : Hue::Client.new
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def run(echo_response)
|
17
17
|
@client.reset
|
18
18
|
|
19
19
|
echo_response.slots.to_h.except(:state).each do |key, value|
|
20
20
|
if value
|
21
|
-
if value.split(' ').last == "light"
|
21
|
+
if value.to_s.split(' ').last == "light"
|
22
22
|
key = "light"
|
23
23
|
value = value[/(.*)\s/,1]
|
24
|
-
elsif value.split(' ').last == "lights"
|
24
|
+
elsif value.to_s.split(' ').last == "lights"
|
25
25
|
key = "lights"
|
26
|
-
value = value.split(' ').count == 1 ? "lights" : value[/(.*)\s/,1]
|
26
|
+
value = value.to_s.split(' ').count == 1 ? "lights" : value[/(.*)\s/,1]
|
27
27
|
end
|
28
28
|
|
29
|
-
value = value.in_numbers if value.scan(Regexp.union( (1..10).map {|k| k.in_words} ) ).any?
|
30
29
|
value = ((value.to_f/10.to_f)*255).to_i if (value.class == Fixnum) && (key.to_s != "fade")
|
31
30
|
@client.send(key.to_sym, value)
|
32
|
-
puts "Calling: #{key}(#{value})"
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
data/lib/alexa_hue/version.rb
CHANGED
data/lib/alexa_hue.rb
CHANGED
@@ -11,24 +11,20 @@ require 'alexa_hue/hue/voice_parser'
|
|
11
11
|
require 'alexa_hue/hue/helpers'
|
12
12
|
require 'chronic_duration'
|
13
13
|
|
14
|
-
LEVELS = {} ; [*1..10].each { |t| LEVELS[t.to_s ] = t.in_words }
|
15
|
-
|
16
14
|
module Hue
|
17
15
|
include Hue::Helpers
|
18
16
|
extend Sinatra::Extension
|
19
17
|
|
20
18
|
helpers do
|
21
|
-
def
|
19
|
+
def voice_parser
|
22
20
|
Hue::VoiceParser.instance
|
23
21
|
end
|
24
22
|
|
25
23
|
def control_lights
|
26
24
|
Thread.start do
|
27
|
-
[:brightness, :saturation].each
|
28
|
-
LEVELS.keys.reverse_each { |level| @echo_request.slots.send(attribute).sub!(level, LEVELS[level]) } if @echo_request.slots.send(attribute) && @echo_request.slots.schedule.nil?
|
29
|
-
end
|
25
|
+
[:brightness, :saturation].each { |attribute| @echo_request.slots.send("#{attribute}=", @echo_request.slots.send(attribute)&.in_numbers) unless @echo_request.slots.schedule }
|
30
26
|
|
31
|
-
|
27
|
+
voice_parser.run @echo_request
|
32
28
|
end
|
33
29
|
|
34
30
|
if (@echo_request.slots.lights.nil? && @echo_request.slots.scene.nil? && @echo_request.slots.savescene.nil?) || (@echo_request.slots.lights && @echo_request.slots.lights.scan(/light|lights/).empty?)
|