alexa_hue 1.1.9 → 1.1.10

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: 8030fd3599afd03b7a36dc1d2332543ac093f1d0
4
- data.tar.gz: 6edabcd9960392315447a371a5a1f1a14dacf7a4
3
+ metadata.gz: b1e651f32e10079e88cb2c5cdaf964db2794716e
4
+ data.tar.gz: 02362df73c6f82fa546239426a1445790918fb66
5
5
  SHA512:
6
- metadata.gz: fddc1858c8bb644fe63785d55764b0ce11839e31dafdc54e5f1a08c1a43132e957cb5ea7f24c207a20ad59bc6403fd14e39fee8aa02ade79ca6813ab72e7130a
7
- data.tar.gz: de9d792688ddc0fd4bcaa2a0d9bcb4906c14019f8420c21344c3fc96e3ee14631ee3da987e9c88c2bca9d8e5d205f19f31c05a78ffa1adb3dd043966b605ef2b
6
+ metadata.gz: 61011accd70997d59ae4d3ca114107525b15a918194dc0f5bcf42cfca92793c7d06d1953dacd6ef7c7bcd7acd263a4b82d8c7170d11e195718690da82f14e8f9
7
+ data.tar.gz: 53ace5796d690a500fcebcd477743bf207e9bfe5414417dea0d5a6e6293a8d82eabcc2c678c49c0417116379ff5ab75423719137014f2c2b97630cd7ab50a681
data/lib/alexa_hue.rb CHANGED
@@ -11,10 +11,8 @@ require 'alexa_hue/hue/voice_parser'
11
11
  require 'alexa_hue/hue/helpers'
12
12
  require 'chronic_duration'
13
13
 
14
-
15
14
  LEVELS = {} ; [*1..10].each { |t| LEVELS[t.to_s ] = t.in_words }
16
15
 
17
-
18
16
  module Hue
19
17
  include Hue::Helpers
20
18
  extend Sinatra::Extension
@@ -25,35 +23,32 @@ module Hue
25
23
  end
26
24
 
27
25
  def control_lights
28
- if @echo_request.slots.brightness
29
- LEVELS.keys.reverse_each { |level| @echo_request.slots.brightness.sub!(level, LEVELS[level]) } if @echo_request.slots.schedule.nil?
30
- end
31
-
32
- if @echo_request.slots.saturation
33
- LEVELS.keys.reverse_each { |level| @echo_request.slots.saturation.sub!(level, LEVELS[level]) } if @echo_request.slots.schedule.nil?
34
- end
26
+ 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
35
30
 
36
- @echo_request.slots.to_h.each do |k,v|
37
- @string ||= ""
38
- next unless v
39
- if k == :scene || k == :alert
40
- @string << "#{v.to_s} #{k.to_s} "
41
- elsif k == :lights || k == :modifier || k == :state
42
- @string << "#{v.to_s} "
43
- elsif k == :savescene
44
- @string << "save scene as #{v.to_s} "
45
- elsif k == :flash
46
- @string << "start long alert "
47
- else
48
- @string << "#{k.to_s} #{v.to_s} "
31
+ @echo_request.slots.to_h.each do |k,v|
32
+ @string ||= ""
33
+ next unless v
34
+ if k == :scene || k == :alert
35
+ @string << "#{v.to_s} #{k.to_s} "
36
+ elsif k == :lights || k == :modifier || k == :state
37
+ @string << "#{v.to_s} "
38
+ elsif k == :savescene
39
+ @string << "save scene as #{v.to_s} "
40
+ elsif k == :flash
41
+ @string << "start long alert "
42
+ else
43
+ @string << "#{k.to_s} #{v.to_s} "
44
+ end
49
45
  end
50
- end
51
46
 
52
- fix_schedule_syntax(@string)
53
- @string.sub!("color loop", "colorloop")
54
- @string.strip!
55
-
56
-
47
+ fix_schedule_syntax(@string)
48
+ @string.sub!("color loop", "colorloop")
49
+ @string.strip!
50
+ switch.voice @string
51
+ end
57
52
 
58
53
  # if @echo_request.slots.lights.nil? && @echo_request.slots.scene.nil? && @echo_request.slots.savescene.nil?
59
54
  # halt AlexaObjects::Response.new(end_session: false, spoken_response: "Please specify which light or lights you'd like to adjust. I'm ready to control the lights.").to_json
@@ -86,7 +81,6 @@ module Hue
86
81
  # halt r.without_card.to_json
87
82
  # end
88
83
  #end
89
- Thread.start { switch.voice @string }
90
84
 
91
85
  return AlexaObjects::Response.new(spoken_response: "okay").to_json
92
86
  end
@@ -1,4 +1,4 @@
1
1
  module Hue
2
- VERSION = "1.1.9"
2
+ VERSION = "1.1.10"
3
3
  end
4
4
 
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.1.9
4
+ version: 1.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Lucas