LUA script to cycle Hue scenes with one button
Posted: Monday 18 December 2017 1:36
Edit: see my post a couple posts down. Fixed the issue by going a different direction with the script. Updated post title to help anyone searching in the future.
Can anyone think of a way to speed up this script? When I activate it multiple times in quick succession, I'm noticing it's not finishing before the next activation, causing unwanted behavior.
This script is called by my harmony remote via habridge. Ideally, I'd like to be able to quickly cycle through the different scenes, but currently have to wait about 5 seconds between each button press.
If it can't be sped up, does anyone know how I might re-do it so that I could, say, click quickly 3 times and that click count would be passed to the uservariable? Thinking that by having it count as the very first step would at least prevent it from needing to process the whole string each time.
Disclaimer: My knowledge is limited and I usually just borrow code and mod it to my needs. Can't really write on my own yet.
Thanks for any ideas!
portions of code borrowed from wormiedk
Can anyone think of a way to speed up this script? When I activate it multiple times in quick succession, I'm noticing it's not finishing before the next activation, causing unwanted behavior.
This script is called by my harmony remote via habridge. Ideally, I'd like to be able to quickly cycle through the different scenes, but currently have to wait about 5 seconds between each button press.
If it can't be sped up, does anyone know how I might re-do it so that I could, say, click quickly 3 times and that click count would be passed to the uservariable? Thinking that by having it count as the very first step would at least prevent it from needing to process the whole string each time.
Disclaimer: My knowledge is limited and I usually just borrow code and mod it to my needs. Can't really write on my own yet.
Thanks for any ideas!
Code: Select all
commandArray = {}
--Living Room
if (devicechanged['Harmony Living Cycle'] == 'On') then
scenes={"Scene Daylight Living","Scene Bright Living","Scene Bias Light Living","Scene Dim Living"}
cur_scene=uservariables["CurLivingScene"]
cur_scene = cur_scene + 1
if (cur_scene==5) then
cur_scene=1
commandArray['Variable:CurLivingScene'] = '1'
print(scenes[cur_scene])
commandArray[scenes[cur_scene]]='On'
else
print(scenes[cur_scene])
commandArray[scenes[cur_scene]]='On'
commandArray['Variable:CurLivingScene'] = tostring(cur_scene)
end
end
if (devicechanged['Harmony Living Cycle'] == 'Off') then
commandArray['Group Living Room']='Off'
commandArray['Variable:CurLivingScene'] = '0'
end
return commandArray