I’m trying to blink a Philips Hue bulb in a lamp, I’m using the AltHue plugin.
I had to change the URN to SwitchPower1 as BinaryLight1 didn’t seem to work.
This code does blink the lamp on and off but I don’t think the count is working fully it doesn’t blink 10 times. The lamp goes on and off about 4 times. The rate is much slower than 2 seconds also.
But its good enough for what I need.
Patrick do you think it would be possible to take in to account the starting status of the lamp if it was on or off to begin with? And after the blink code return that lamp to its prior on or off status?
With the code as is, if the lamp was already ON to begin with after the blinking the lamp then remains OFF.
If the lamp was OFF to begin with after the blinking it is still OFF.
Or is it just chance on how many blinks you have set and what the starting state of the lamp was.
device = 379 -- device number to blink
count = 10 -- number of times to blink
rate = 2 -- number of seconds between blinks
function blink_on()
luup.call_action( "urn:upnp-org:serviceId:SwitchPower1", "SetTarget", { newTargetValue="1" }, device )
luup.call_delay( 'blink_off', rate )
end
function blink_off()
luup.call_action( "urn:upnp-org:serviceId:SwitchPower1", "SetTarget", { newTargetValue="0" }, device )
count = count - 1
if count > 0 then
luup.call_delay( 'blink_on', rate )
end
end
-- Start blinking
blink_on()