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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a8279f7243276431c830a00b52f689fc6f2a335
4
- data.tar.gz: 904de5cd7fb0ca4c6770c614e5c36475a9cb8f3a
3
+ metadata.gz: 40a90ef5b2445e359556fa8742c82678c9e22e7f
4
+ data.tar.gz: d6f773a6d0cf794281feb524b8c3dea86de639a3
5
5
  SHA512:
6
- metadata.gz: 2afeb307b65861a95bfa926393d63bcff6cbcad432240b22c2c02279108e69f242c0d5a2a9dd420a58364c92e60865fa5a506f66051b35409e2122f28a9fb4a3
7
- data.tar.gz: 041321635e647fcc8b66b12cdc75880d7ac20e933d0ba3ed51c8a6358220ce9d2e268444c3bdc47df0048cdb106939f6b92df5d5aeea45e0886327cc5ed5600a
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 voice(echo_response)
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
 
@@ -1,4 +1,4 @@
1
1
  module Hue
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
4
4
 
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 switch
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 do |attribute|
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
- switch.voice @echo_request
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?)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexa_hue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Lucas