class Yeelight::Lamp
Constants
- VALUES
Attributes
client[R]
Public Class Methods
new(client)
click to toggle source
# File lib/yeelight/lamp.rb, line 7 def initialize(client) @client = client end
Public Instance Methods
toggle_color(color_hex, duration = 1)
click to toggle source
# File lib/yeelight/lamp.rb, line 11 def toggle_color(color_hex, duration = 1) color = "0x#{color_hex}".to_i(16) rgb, ct, color_mode, hue, sat = JSON.parse(client.get_prop(VALUES))['data']['result'] client.set_rgb(color, 'smooth', 500) sleep duration case color_mode.to_i when 1 client.set_rgb(rgb, 'smooth', 500) when 2 client.set_ct_abx(ct, 'smooth', 500) when 3 client.set_hsv(hue, sat, 'smooth', 500) end end