Help with rules sequence - restore light to previous setting
Help with rules sequence - restore light to previous setting
I'm using an outdoor motion sensor with a light.
I want the light to flash one time with a specific colour and brightness, if the conditions of presence detected and dark are both met.
I have created a rule to do this and it works OK.
What I want to also do is to have the light return to its previous state, colour, brightness, on or off (i.e. OFF it was off before the presence was detected or ON if it was on before the presence was detected).
I cannot figure out how to do this in the rules so I'm looking for help.
The light is an indoor lamp that is not used in any other scenes or sequences and is only sometimes turned on in the evenings manually via the app ON/OFF.
TIA
I want the light to flash one time with a specific colour and brightness, if the conditions of presence detected and dark are both met.
I have created a rule to do this and it works OK.
What I want to also do is to have the light return to its previous state, colour, brightness, on or off (i.e. OFF it was off before the presence was detected or ON if it was on before the presence was detected).
I cannot figure out how to do this in the rules so I'm looking for help.
The light is an indoor lamp that is not used in any other scenes or sequences and is only sometimes turned on in the evenings manually via the app ON/OFF.
TIA
Re: Help with rules sequence - restore light to previous setting
Since nobody is answering I'm going to give it a try.
This ist not easily done due to hardware limitations. Maybe this why nobody replies to your question. The Hue system is neither able to store values from generic devices/sensors nor can it restore data to them.
The only thing you can do is to register scenes for all desired lights and color settings and create an additional generic memory sensor. Whenever a specific scene is set a corresponding value is written to the memory sensor by the rule that activates the scene. Now when you want to return to a previous state you create a rule for every possible value stored and reactivate the corresponding scene. This would unfortunately force you to disable manual operations.
Maybe there is another better option but that's what I could come up with - hope it helps.
This ist not easily done due to hardware limitations. Maybe this why nobody replies to your question. The Hue system is neither able to store values from generic devices/sensors nor can it restore data to them.
The only thing you can do is to register scenes for all desired lights and color settings and create an additional generic memory sensor. Whenever a specific scene is set a corresponding value is written to the memory sensor by the rule that activates the scene. Now when you want to return to a previous state you create a rule for every possible value stored and reactivate the corresponding scene. This would unfortunately force you to disable manual operations.
Maybe there is another better option but that's what I could come up with - hope it helps.
Re: Help with rules sequence - restore light to previous setting
@inc
Thanks for trying to solve my problem. Much appreciated. I'll continue trying things out but it's not easy.
Maybe somebody else will come up with some specific steps?
HTB
Thanks for trying to solve my problem. Much appreciated. I'll continue trying things out but it's not easy.
Maybe somebody else will come up with some specific steps?
HTB
Re: Help with rules sequence - restore light to previous setting
Hello Tia,
I believe you could store the previous state in a scene, if you delay your blinking action (using a timer and memory sensor, or another rule with identical conditions but delay in the trigger), and afterwards apply the stored scene again.
Regards,
Marcus
I believe you could store the previous state in a scene, if you delay your blinking action (using a timer and memory sensor, or another rule with identical conditions but delay in the trigger), and afterwards apply the stored scene again.
Regards,
Marcus
2x Bridge V2 (+deCONZ/HA-Bridge)
Hue Go (+BT), Lightstrip (in/out), Play, Bloom; E14+E27 Bulb; Iris, Aura.
Motion sensor (in/out), Dimmer (old/new), Smart Button, Tap Dial.
P.S.: Ich bin *kein* Entwickler von all 4 hue, aber Hue Poweruser!
Hue Go (+BT), Lightstrip (in/out), Play, Bloom; E14+E27 Bulb; Iris, Aura.
Motion sensor (in/out), Dimmer (old/new), Smart Button, Tap Dial.
P.S.: Ich bin *kein* Entwickler von all 4 hue, aber Hue Poweruser!
Re: Help with rules sequence - restore light to previous setting
@MarcusZ - thanks ever so much for trying to help me. It's much appreciated! BTW I am HTB, TIA is the acronym for "thanks in anticipation." However apologies for the confusion as I'm aware this is not primarily an English language forum.MarcusZ. wrote: ↑Tue Feb 04, 2020 9:52 am Hello Tia,
I believe you could store the previous state in a scene, if you delay your blinking action (using a timer and memory sensor, or another rule with identical conditions but delay in the trigger), and afterwards apply the stored scene again.
Regards,
Marcus
Anyhow your suggestion is beyond my knowledge as I don't know how to delay triggers or use timers and memory sensors!
I can get as far as to make the light flash once (RED), starting from an initial condition of the light being ON (WARM WHITE). I also have another rule that makes the light flash once (RED), starting from an initial condition of the light being OFF.
The 2 rules look like this:
1. Hue outdoor ambient light sensor = "It is dark" + Living room = "All lights are on" + Hue outdoor motion sensor = "Sensor status updated" + Hue outdoor motion sensor = "Presence detected" THEN ACTIONS --> Living room = "Set brightness to 100%" + Living room = "Set color RED" + Living room "Flash light once"
2. Hue outdoor ambient light sensor = "It is dark" + Living room = "All lights are off" + Hue outdoor motion sensor = "Sensor status updated" + Hue outdoor motion sensor = "Presence detected" THEN ACTIONS --> Living room = "Set brightness to 100%" + Living room = "Set color RED" + Living room "Flash light once"
The above rules work OK but in both cases the light then stays on in bright RED.
For Rule 1 I have tried to add an action after "Flash lights once" that states: Living room light normally ON = "Activate scene" where I have a saved scene with the light ON in Warm White. However I cannot get this to work.
For Rule 2 I have tried to add an action after "Flash lights once" that states: Living room OFF = "Start timer" where I have a saved 1 second timer. This saved timer should trigger the Living room OFF. Again, however I cannot get this to work.
For both rules the light stays on bright red.
I think the answer possibly exists in memory values and timers and scenes but I do not understand enough of how these work.
I really need somebody to show me step-by-step how to set this up.
HTB
Re: Help with rules sequence - restore light to previous setting
Hello HTB oO,
thanks for the update, describing you current rules. That is a good point to start.
Nobody knows why philips did not include a 'flash light once in a specific color' effect, and why it is not allowed to set a color for a light which is turned off. That is why we may have to build rather complicated workarounds.
But on the other hand, your use case is nice to learn a lot about most parts of Hue rules and its parts.
Let's first try to improve your existing rules, by introducing a memory sensor (which we will anyway need later) to also reduce "redundancy".
It is not few work, but just try to follow it step by step. I hope it is easily understandable, so you can use the same method also for other use cases in the future. (Because I don't have a device with an english OS here, I hope my translation of the terms is not so wrong. And as this was recapitulated from mind, I cannot give a 100% guarantee, but still am optimistic that it will work this way).
1) Create a memory sensor for numeric values (should be in an "accessories" section) and change its name directly afterwards to e.g. "OUT, MotionWhenDark"
2) Clone the first rule. When you tap on it, there should be a menu item to do so. (The copied rule should appear shortly afterwards, and is disabled, which is okay for now.)
3) Open the original first rule and remove the condition: Living room = "All lights are on". It then has just the conditions which are identical in both of your original rules. Remove the existing actions and just add one action, to store a numeric value into the previously created memory sensor, let's say the value 1.
4) Now modify the copied rule. Remove all conditions, except: Living room = "All lights are on". Add another condition for a numeric memory sensor (select regular condition here - a trigger will be added later). Chose the sensor "OUT, MotionWhenDark", scroll down to set it to "equals", and insert 1 in the number field. When going back then and saving the rule afterwards, you should be asked whether a trigger condition should be added. Select the memory sensor as the trigger. Doing so you decide that the rule should be evaluated when the memory sensor is updated with a value of 1 (in contrary to another way for interpretation: the sensor could already have a value of 1, and the lights being turned on afterwards). Activate the copied rule afterwards.
At that point, we did a bit of work to ... just have the same behavior as before. But don't be sad, the benefit of this 'refactoring' will come soon. You could name the first rule to "OUT, DetectMotionWhenDark" and the copied one to "OUT Motion, LR on, blink red". This is just an example - having a systematic naming schema (which has to work for you!) helps a lot when the number of rules rises, as the rules are usually ordered by their names.
Maybe you already have an idea what comes next: Improve the "All lights are off" rule.
5) Do the modifications like in step 4 above, but just for the "All lights are off" rule (and using "off" instead of "on"). It should afterwards still work the same way as before.
Now we begin working on the real problem, by splitting it to individual steps:
- store the lightstates into a scene (when motion is detected, but before the blinking)
- do the blinking
- apply the previously saved scene (which could also be holding the state "all lights off" - just as a remark)
In the next step we will use the possibility to delay execution of rule actions. Before doing so, you may clone the affected rule (for having a rule with the same conditions later, without much work - deleting parts of cloned rules is in most cases easier than trying to create a new rule and manually adding the required items, identically).
6) Modify the rule which I would refer to as "OUT Motion, LR on, blink red" (after having created a clone for future usage). Tap on the automatically created trigger condition which should be labeled like "sensor state updated" to modify it. Scroll down then to set the mode to delay, with a value of "00:00:05". That is more than enough time to store the previous state of the lights to a scene (in another rule) before blinking. And you should be able to try out and notice the difference to a rule without delay. Got it working?
7) Create a new scene for storing and restoring the Living room lights' states. Just select the relevant lights for it (or a group containing those lights) and proceed to the point of naming the scene - you can choose colors for testing the scene, but there is no need for it, as the scene will be automatically updated by a rule later. The name for the scene could be like 'LR, storedScene'.
8) Modify the cloned rule, which does still have the regular (not delayed) trigger. Delete the existing actions, and add one action 'store light states to scene'. Select the previously created scene. Activate the rule, and name it accordingly. The scene should now be updated with the current state of the lights whenever motion is detected outside (while dark, and LR lights are on).
Now let's check again the required steps. You still need to recall the stored scene after the blinking has occured. There are several possibilities to do so - but it is not working to just do it in the existing rule "below" the blinking part. Below does not always mean "after", especially for longer lasting operations. The rule just "tells" the light to blink and proceeds to the next step without waiting. The same is true when you start a timer in a rule: the rule does not wait until the timer is elapsed!
I believe you will be able to complete this on your own, in one of the following ways:
- Create a timer with 2 seconds, which recalls the stored scene as action. Start this timer "below" the part with the blinking. If this works, change the timer to 1 second and try if that works better/worse.
OR
- add an action below the part with the blinking, to set the memory sensor "OUT, MotionWhenDark" to a value of 2 (="prepare scene recall"). Then you can create another rule which reacts just on this value change, again with a delay of 1 or 2 seconds in the trigger, to then recall the scene as "simple" rule action without using a timer, and set the sensor "OUT, MotionWhenDark" to a value of 0 (="finished").
For this use case, the second way would probably not have advantages over the first way. But for other ideas it may allow establishing a state model, with well defined transitions, but is probably a bit more complicated and requires further work to get it right. (Think about a traffic light, which goes from "red" [0] via "red+yellow" [1] to "green" [2], and then via "yellow" [3] back to "red" [0] - and usually no other ways.)
As this already got a bit longer, let's take a break here and first see how you get along with it. In case I forgot something or you get stuck at a point, feel free to get back and ask.
Kind regards,
Marcus
P.S.:
Your TIA sounds much better, so thank you for solving a mystery. ^^
thanks for the update, describing you current rules. That is a good point to start.
Nobody knows why philips did not include a 'flash light once in a specific color' effect, and why it is not allowed to set a color for a light which is turned off. That is why we may have to build rather complicated workarounds.
But on the other hand, your use case is nice to learn a lot about most parts of Hue rules and its parts.
Let's first try to improve your existing rules, by introducing a memory sensor (which we will anyway need later) to also reduce "redundancy".
It is not few work, but just try to follow it step by step. I hope it is easily understandable, so you can use the same method also for other use cases in the future. (Because I don't have a device with an english OS here, I hope my translation of the terms is not so wrong. And as this was recapitulated from mind, I cannot give a 100% guarantee, but still am optimistic that it will work this way).
1) Create a memory sensor for numeric values (should be in an "accessories" section) and change its name directly afterwards to e.g. "OUT, MotionWhenDark"
2) Clone the first rule. When you tap on it, there should be a menu item to do so. (The copied rule should appear shortly afterwards, and is disabled, which is okay for now.)
3) Open the original first rule and remove the condition: Living room = "All lights are on". It then has just the conditions which are identical in both of your original rules. Remove the existing actions and just add one action, to store a numeric value into the previously created memory sensor, let's say the value 1.
4) Now modify the copied rule. Remove all conditions, except: Living room = "All lights are on". Add another condition for a numeric memory sensor (select regular condition here - a trigger will be added later). Chose the sensor "OUT, MotionWhenDark", scroll down to set it to "equals", and insert 1 in the number field. When going back then and saving the rule afterwards, you should be asked whether a trigger condition should be added. Select the memory sensor as the trigger. Doing so you decide that the rule should be evaluated when the memory sensor is updated with a value of 1 (in contrary to another way for interpretation: the sensor could already have a value of 1, and the lights being turned on afterwards). Activate the copied rule afterwards.
At that point, we did a bit of work to ... just have the same behavior as before. But don't be sad, the benefit of this 'refactoring' will come soon. You could name the first rule to "OUT, DetectMotionWhenDark" and the copied one to "OUT Motion, LR on, blink red". This is just an example - having a systematic naming schema (which has to work for you!) helps a lot when the number of rules rises, as the rules are usually ordered by their names.
Maybe you already have an idea what comes next: Improve the "All lights are off" rule.
5) Do the modifications like in step 4 above, but just for the "All lights are off" rule (and using "off" instead of "on"). It should afterwards still work the same way as before.
Now we begin working on the real problem, by splitting it to individual steps:
- store the lightstates into a scene (when motion is detected, but before the blinking)
- do the blinking
- apply the previously saved scene (which could also be holding the state "all lights off" - just as a remark)
In the next step we will use the possibility to delay execution of rule actions. Before doing so, you may clone the affected rule (for having a rule with the same conditions later, without much work - deleting parts of cloned rules is in most cases easier than trying to create a new rule and manually adding the required items, identically).
6) Modify the rule which I would refer to as "OUT Motion, LR on, blink red" (after having created a clone for future usage). Tap on the automatically created trigger condition which should be labeled like "sensor state updated" to modify it. Scroll down then to set the mode to delay, with a value of "00:00:05". That is more than enough time to store the previous state of the lights to a scene (in another rule) before blinking. And you should be able to try out and notice the difference to a rule without delay. Got it working?
7) Create a new scene for storing and restoring the Living room lights' states. Just select the relevant lights for it (or a group containing those lights) and proceed to the point of naming the scene - you can choose colors for testing the scene, but there is no need for it, as the scene will be automatically updated by a rule later. The name for the scene could be like 'LR, storedScene'.
8) Modify the cloned rule, which does still have the regular (not delayed) trigger. Delete the existing actions, and add one action 'store light states to scene'. Select the previously created scene. Activate the rule, and name it accordingly. The scene should now be updated with the current state of the lights whenever motion is detected outside (while dark, and LR lights are on).
Now let's check again the required steps. You still need to recall the stored scene after the blinking has occured. There are several possibilities to do so - but it is not working to just do it in the existing rule "below" the blinking part. Below does not always mean "after", especially for longer lasting operations. The rule just "tells" the light to blink and proceeds to the next step without waiting. The same is true when you start a timer in a rule: the rule does not wait until the timer is elapsed!
I believe you will be able to complete this on your own, in one of the following ways:
- Create a timer with 2 seconds, which recalls the stored scene as action. Start this timer "below" the part with the blinking. If this works, change the timer to 1 second and try if that works better/worse.
OR
- add an action below the part with the blinking, to set the memory sensor "OUT, MotionWhenDark" to a value of 2 (="prepare scene recall"). Then you can create another rule which reacts just on this value change, again with a delay of 1 or 2 seconds in the trigger, to then recall the scene as "simple" rule action without using a timer, and set the sensor "OUT, MotionWhenDark" to a value of 0 (="finished").
For this use case, the second way would probably not have advantages over the first way. But for other ideas it may allow establishing a state model, with well defined transitions, but is probably a bit more complicated and requires further work to get it right. (Think about a traffic light, which goes from "red" [0] via "red+yellow" [1] to "green" [2], and then via "yellow" [3] back to "red" [0] - and usually no other ways.)
As this already got a bit longer, let's take a break here and first see how you get along with it. In case I forgot something or you get stuck at a point, feel free to get back and ask.
Kind regards,
Marcus
P.S.:
Fun fact: our former english teacher (texan) told us that many germans use 'thanks in advance' - and that it is wrong (because no native speaker would say so). But as far as I remember, he offered no alternative.
Your TIA sounds much better, so thank you for solving a mystery. ^^
2x Bridge V2 (+deCONZ/HA-Bridge)
Hue Go (+BT), Lightstrip (in/out), Play, Bloom; E14+E27 Bulb; Iris, Aura.
Motion sensor (in/out), Dimmer (old/new), Smart Button, Tap Dial.
P.S.: Ich bin *kein* Entwickler von all 4 hue, aber Hue Poweruser!
Hue Go (+BT), Lightstrip (in/out), Play, Bloom; E14+E27 Bulb; Iris, Aura.
Motion sensor (in/out), Dimmer (old/new), Smart Button, Tap Dial.
P.S.: Ich bin *kein* Entwickler von all 4 hue, aber Hue Poweruser!
Re: Help with rules sequence - restore light to previous setting
@MarcusZ
Wow! Thanks for such a comprehensive response. Amazing and so helpful. I will try out your suggestions this weekend and let you know how it goes.
BTW, IIRC (&FWIW) your Texan was partly correct. TIA is not common in spoken English and is very specific to the Internet (like BTW, IIRC & FWIW etc). Its origins are in Internet Relay Chat of the mid-90s and SMS text messaging (pre-smart phone). Today you would only see it in a forum but it's become a bit Old Skool.
Wow! Thanks for such a comprehensive response. Amazing and so helpful. I will try out your suggestions this weekend and let you know how it goes.
BTW, IIRC (&FWIW) your Texan was partly correct. TIA is not common in spoken English and is very specific to the Internet (like BTW, IIRC & FWIW etc). Its origins are in Internet Relay Chat of the mid-90s and SMS text messaging (pre-smart phone). Today you would only see it in a forum but it's become a bit Old Skool.