Hi, I have the following project. I have 4 dimmers (that support instant status) that I want to be somehow linked in a complex way. Here is my idea:
[ol][li]If all of them are off, and any of it is turned on to 100%, it has to start a 4 mins sequence where the other three also turns on (it could be to 99% so they don’t get into a loop?). After two minutes, goes to 50% loadstatus and two minutes later, the four are turned off.[/li]
[li]If number one is running and any of those is set again to 100%, the sequence starts over.[/li]
[li]If any of those is turned off while the sequence is running, the rest will also turn off and break the remaining sequence.[/li]
[li]If any of those is set to a different level than those specified in the sequence (100%, 99%, 50%), that one, and the rest, should be set to that level indefinitely and break the sequence until they come back to 100% or 0% and that would be satisfying point 1 or 3 respectively.[/li][/ol]
Currently I am running something similar with scenes, the problem is that if the scene is started more than one time before it ends, it goes crazy and sometimes lights remain on and other times they go up and down between levels until they get off. Its crazy, I think vera can’t cancel a running scene once it is running even if it starts running again, two instances or more can be running.
That shouldn’t be too hard to do using PLEG with the help of LogicTimer to provide the timed sequences.
Set up PLEG conditions to detect your four scenarios. Use the associated actions to start or stop LogicTimer with an appropriate Flag string. You can use Flag as a state indicator (“Idle”, “Manual”, “Time1”, “Time2”…). You can set or test Flag regardless of whether the timer is running or not. Add conditions fired by LogicTimer ending with tests for each value of Flag and set the associated actions to control your lights and start the next timer or return to “Idle” state.
@RexBecket@RichardTSchaefer, I have been playing arround with PLEG and TimerLogic, I think I am starting to understand, I have make some test scenes and they work, but the scenario I wrote before, I haven’t configured it yet, but I have made my plan in notepad and here it is. Could you please help me a little to see if it is well planned so I can go on an put it on PLEG?
CONDITIONS: turn_stairs_100 (stairs_door_status == 100) OR (stairs_kitchen_status == 100) OR (stairs_bedroom_status == 100) OR (stairs_roof_status == 100) turn_stairs_ 80 (stairs_door_status == 100) OR (stairs_kitchen_status == 100) OR (stairs_bedroom_status == 100) OR (stairs_roof_status == 100) AND (stairs_timer_flag == stairs_100) AND (NOT stairs_timer_on) turn_stairs_50 (stairs_door_status == 80) OR (stairs_kitchen_status == 80) OR (stairs_bedroom_status == 80) OR (stairs_roof_status == 80) AND (stairs_timer_flag == stairs_80) AND (NOT stairs_timer_on) turn_stairs_30 (stairs_door_status == 50) OR (stairs_kitchen_status == 50) OR (stairs_bedroom_status == 50) OR (stairs_roof_status == 50) AND (stairs_timer_flag == stairs_50) AND (NOT stairs_timer_on) turn_stairs_off (stairs_door_status == 30) OR (stairs_kitchen_status == 30) OR (stairs_bedroom_status == 30) OR (stairs_roof_status == 30) AND (stairs_timer_flag == stairs_30) AND (NOT stairs_timer_on) break_stairs_sequence (stairs_door_status == 0) OR (stairs_kitchen_status == 0) OR (stairs_bedroom_status == 0) OR (stairs_roof_status == 0) break_stairs_seq_and_set_dim (NOT stairs_door_status == 100) AND (NOT stairs_kitchen_status == 100) AND (NOT stairs_bedroom_status == 100) AND (NOT stairs_roof_status == 100) AND (NOT stairs_door_status == 80) AND (NOT stairs_kitchen_status == 80) AND (NOT stairs_bedroom_status == 80) AND (NOT stairs_roof_status == 80) AND (NOT stairs_door_status == 50) AND (NOT stairs_kitchen_status == 50) AND (NOT stairs_bedroom_status == 50) AND (NOT stairs_roof_status == 50) AND (NOT stairs_door_status == 30) AND (NOT stairs_kitchen_status == 30) AND (NOT stairs_bedroom_status == 30) AND (NOT stairs_roof_status == 30) AND (NOT stairs_door_status == 0) AND (NOT stairs_kitchen_status == 0) AND (NOT stairs_bedroom_status == 0) AND (NOT stairs_roof_status == 0)
ACTIONS: turn_stairs_100 stop timer, restart timer, start timer 00:02:00, set flag stairs_100, turn 100 all lights turn_stairs_ 80 start timer 00:01:00, set flag stairs_80, turn 80 all lights turn_stairs_50 start timer 00:01:00, set flag stairs_50, turn 50 all lights turn_stairs_30 start timer 00:01:00, set flag stairs_30, turn 30 all lights turn_stairs_off start timer 00:01:00, set flag stairs_off, turn off all lights break_stairs_sequence stop timer, restart timer, start timer 00:02:00, set flag stairs_dim, turn {status} all lights
I have not attempted to check all your logic - that’s really down to you. ;D I do have some comments, though:
In your conditions where you are testing stairs_timer_flag, you should use eq “stairs_100” rather than == stairs_100. The Flag property is a string so needs to be tested as such.
In your conditions with multiple OR terms plus AND terms, group the OR terms in parenthesis. E.g. turn_stairs_ 80 ( (stairs_door_status == 100) OR (stairs_kitchen_status == 100) OR (stairs_bedroom_status == 100) OR (stairs_roof_status == 100) ) AND (stairs_timer_flag eq “stairs_100”) AND (NOT stairs_timer_on)
In your actions, there is no need to restart LogicTimer after stopping it and before starting it. Provided the timer is stopped, a start command will set it running with the new timer value and flag. The restart action is provided for those who disable LogicTimer’s default auto-restart on Vera restart by setting Mode to 1 (I don’t know why anyone would want to but I made it an option). A timer will only be restarted if the original end-time has not been reached.
I don’t understand why you are starting the timer in the action break_stairs_sequence. I believe you would just want to set the timer flag to, say, “Manual” and then stop the timer. I also don’t see why you need to start the timer in the action turn_stairs_off.
I note you haven’t shown how you derive status for setting the other lights with the action for break_stairs_seq_and_set_dim. That could be tricky to do. I would be inclined to split the break_stairs_seq_and_set_dim condition and associated action into four - one for each light. That way you know which status property to use for the three other lights.
It shouldn’t stop it working but it feels to me that your trigger stairs_timer_on is upside-down so you have to use NOT (stairs_timer_on) in the conditions. If you invert the trigger: timer_endstairs_timer has ended, you would not need the NOTs.
You must really like typing to use such long labels for everything… :o
I finally did it!! Thanks for your tips! I am attaching a report, I think it could be interesting for other people in the forum.
Thank you for all your observations, and just for the record, I use long labels because when I am analyzing the status reportes, it makes more easy to remember the logic hehe, just a little more typing for less time analyzing.
@RichardTSchaefer, I have a lot of 1 (ones) at the end of my condition names! I don’t know why this is happening, it happens even the first time I create a condition, it appends the 1. Everything is working fine, but makes my think about the Ghost Actions in previous versions?? Is there a way to check/fix? I have a very complex PLEG now and redoing it all from scratch could really become a pain…!!
I’m happy to hear that you’ve got it working. This would have been very hard to achieve without PLEG.
I’m sure @RichardTSchaefer will be able to help you locate and remove your lurking conditions in an efficient way. I have had this happen in the past when I deleted a PLEG and then created a new one - which got the same device ID and inherited parts of the old configuration. I thought that was fixed a while back, though. It is also good practice to delete the actions for a condition before deleting the condition - although I think RTS fixed that too.
Hi again, can you help me with a little detail I am having? It happens that if my Vera restarts (because of a schedule or because I hit save or whatever reason) when it restarts, if it was in the middle of all this show, the timer is stopped, so the lights won’t come off. In this case, I have to either manually turn them off as if they where in Manual Mode, or get them back to 100% so a condition is satisfied and they become all off or back into automatic mode.
Yes Richard, thankyou, but the logic is more complex, I could not accomplish the whole thing without LogicTimer working with PLEG, because it has some conditions that break the sequence or change it to manual mode.
LogicTimer will restart a running timer - if the target time has not been reached. If the target time has already been exceeded, LogicTimer will not restart the timer but will signal that it has ended. This should trigger your logic as if the timer had elapsed normally.
Are you still getting the problem, though? Does PLEG status show that LogicTimer did end during the restart? It does occur to me that the status change could get lost with everything restarting at the same time. If this was a problem, I could delay LogicTimer’s initialisation for, say, 30 seconds to allow everything else to stabilize.
@RexBeckett, until now I think it is working fine, maybe because when I tried the restarts manually, it has plenty of time to start Vera before the timer ends, but I remember that when I first make you the comment, it was because it failed, and it was an automatic restart. Maybe, as you say, it fails when it is to close to the restart before loading all. I will keep you posted if I note something else.
Having looked at my log during a restart, I do think that there is a possibility that a timer-ended event could be missed. I have changed LogicTimer so that, if a timer was running before a restart, it will wait 30 seconds before either restarting it (if the end time has not been reached) or signalling that it has ended. It will show in the log if it restarted or ended a running timer.
Only I_LogicTimer1.xml has changed (attached). I have also updated the file in the main LogicTimer thread.