我们买了几个LIFX灯泡,我要求编写ruby代码来根据特定事件使LIFX闪烁。
我找不到任何能让它闪烁的例子,谁知道是怎么回事?使用官方gem的一些代码示例将不胜感激
LIFX Website
发布于 2015-01-09 05:32:25
安装lifx gem后,您可以尝试以下操作:
require 'lifx'
# set the label of the bulb you want to "flicker"
label = 'YourBulbLabel'
client = LIFX::Client.lan
# find the light with the label you have set in your LAN
client.discover! do |c|
c.lights.with_label(label)
end
# turn on the lights
client.lights.turn_on
light = client.lights.with_label(label)
# make it flicker
light.set_color(LIFX::Color.hsbk(259, 0.1, 0.5, 5000), duration: 1)
sleep 1
light.set_color(LIFX::Color.hsbk(259, 1, 1, 5000), duration: 1)
sleep 1
light.set_color(LIFX::Color.hsbk(259, 0.1, 0.5, 5000), duration: 1)
sleep 1希望这篇文章能让你入门,文档对我帮助很大:http://www.rubydoc.info/github/lifx/lifx-gem/master/LIFX/
https://stackoverflow.com/questions/25130881
复制相似问题