How can I create a scene or the luup code so that when I run the scene in the morning it will disable one scene scheduled later that day (but only once, not forever)?
Put this code in the scene that disables the other scene:
local disableSceneFlag = luup.variable_get ("urn:micasaverde-com:serviceId:DisableSceneFlag1", "DisableSceneFlag", 0) or ""
if (disableSceneFlag == "") then
luup.variable_set ("urn:micasaverde-com:serviceId:DisableSceneFlag1", "disableSceneFlag", "1", 0)
end
And this code in the scene that must be disabled once:
local disableSceneFlag = luup.variable_get ("urn:micasaverde-com:serviceId:DisableSceneFlag1", "DisableSceneFlag", 0)
if (disableSceneFlag == "1") then
luup.variable_set ("urn:micasaverde-com:serviceId:DisableSceneFlag1", "disableSceneFlag", "0", 0)
return false
end
return true
This whole setup works only once. If you need to repeat this regularly you need to manually delete the DisableSceneFlag variable.
I would also shoot for using a unique/new [tt]serviceId[/tt], one that doesn’t use the [tt]urn:micasaverde-com[/tt] namespace.
This’ll make the Variable values stand out as something “custom” in the future, or if anyone runs diag on your Box.
I’m sorry but I did not get it to work. How does this code look when the scene is disabled?
[code]local disableSceneFlag = luup.variable_get (“urn:micasaverde-com:serviceId:DisableSceneFlag1”, “DisableSceneFlag”, 0)
if (disableSceneFlag == “1”) then
luup.variable_set (“urn:micasaverde-com:serviceId:DisableSceneFlag1”, “disableSceneFlag”, “0”, 0)
return false
end
return true[/code]
I would also shoot for using a unique/new serviceId, one that doesn't use the urn:micasaverde-com namespace.Can you hint to any directions of what name spaces that I should use?
The code that goes in the scene that disables the other scene (let’s call it scene A) checks if the DisableSceneFlag exists, and if it doesn’t, it creates it with the value “1”. If the flag exists, the code doesn’t do anything.
The code that goes in the scene to be disabled (scene B) checks if the flag is “1”. If it is, it sets the flag to “0” and the scene doesn’t run. If it’s not, the code doesn’t do anything.
For the subsequent scene A runs, the flag will exist and it will be “0” or “1”, which means that the code won’t do anything. For the subsequent scene B runs, the flag will be “0”, and again, the code won’t do anything. So both scenes will run normally.
Deleting the flag will reset the whole setup.
You can use something like this “urn:HouseBot:serviceId:DisableSceneFlag1”.
I think my issue is to get the first scene to trigger the second scene. Atleast I can’t get the Luup code to change. Is it under Events tab and Device: Scene Controller, or a’m I totally off?
The code must be placed in the scene’s Luup Code input box. It won’t change. Only the DisableSceneFlag will change, and it can be seen in the user_data.