sjenkins Posted 4 hours ago Posted 4 hours ago (edited) Pre-amble: When I started with my shiny new 994 over 10 years ago I was struck with something missing. The environment was familiar, with a state machine controlling I/O. As a young engineer almost 40 years ago I did my share of PLC programming. Scenes were new, but made sense. But the timers were missing. From relay logic days or PLC ladder logic, I was missing my on / off timer relays. I use timers all over the place on my (994, Polisy, Eisy) and always considered them a bit of a PITA to set-up and maintain. Turn-on a light group which I want to turn off in 10min takes a scene, static variable, set the init so you have persistence, then usually have a program for LightON, LightCountdown, LightOFF, depending on the trigger conditions. So, sorry for the pre-amble but that is why these three new devices exist. Virtual offDelay, onDelay, Toggle Please try them out, see if the behaviour is how you would like ; try to break them! From the github README: (note, the README is not the plugin CONFIG file which contains config pointers) let me know of any doc improvements. I tried to up the game a bit on them. offDelay switch Usage: Replaces programs simulating timers used to switch scene off after delay time. For example you turn on a light scene which you want to turn off after x-seconds. The scene is switched on by a switch/program & fires offDelay, after x-seconds the scene is turned off. if Switched: On (DON) when ST Off/On, ST status set to TIMER, CMD (DON), after DUR (DOF). On (DON) during ST TIMER, reset the time, CMD (DOF) sent AFTER DUR seconds. Off during TIMER, ST status changes to Off, CMD DOF sent immediately. Fast On / Off mirror On / Off Set: delay (DUR) to delay seconds for switch, after CMD DON wait to send DOF. range 0 - 99999 seconds which gives you more than 24 hrs. if 0, mostly acts like a regular switch. Status: Off(0), On(1), TIMER(2) When plugin is stopped, if ST is TIMER, ST will be set to On for persistence. Using Thread timers to fire switch, so for now I am not showing a status of how long left in the timer. Trying to keep a low overhead. onDelay switch Usage: Replaces programs simulating timers and scene trigger for transition from one scene to another. For example you turn on a high level light scene which you want to transition to a normal level later. Use two scenes, one High, one Normal/Low, switch on High for x-seconds, after delay then transition to Normal/Low. High scene: onDelay is Responder, set delay (DUR) to x-seconds Normal/Low scene: on Delay is Controller in Normal scene, sending appropriate commands to each device. If switched: On (DON) when ST Off/On, ST status set to TIMER, CMD (DON) after DUR delay. On (DON) during ST TIMER, reset the time, no CMD sent until DUR complete. Off (DOF) during TIMER, ignore until TIMER done. Off (DOF) when ST Off/On, ST status set to Off, send DOF immediately. Fast On (DFON) behaviour is equivalent to on (DON). Fast Off (DFOF) anytime to set ST status to off, CMD (DFOF) sent immediately; this method to cancel is used to allow use and control in a scene. Set: delay (DUR) to seconds switch will, after receiving DON, wait to CMD DON. range 0 - 99999 seconds which gives you more than 24 hrs. if 0, mostly acts like a regular switch. Status: Off(0), On(1), TIMER(2) When plugin is stopped, if ST is TIMER, ST set to On for persistence. Using Thread timers to fire switch, so for now I am not showing a status of how long left in the timer. Trying to keep a low overhead. toggle oscillator Usage: Replaces anywhere you want a scene to oscillate On/OFF. It does not need to be balanced, so allows you to be Off for long periods and On for a short one. Can of course be used to trigger programs on a regular interval as well. An obvious example is blinking Christmas lights. Another would be for attention getting or security flashing. Firing a program at regular intervals can be pretty useful. If switched: On (DON) when ST Off/On, ST status set to onTimer, CMD (DON) immediately. On (DON) when ST onTimer/offTimer, timer reset, CMD (DON) immediately. Off (DOF) when ST onTimer/offTimer, no effect. Off (DOF) when ST Off/On, ST status set to Off, CMD (DOF) immediately. Fast On (DFON) same as On (DON). Fast Off (DFOF) all ST, ST set to Off, CMD (DFOF), cancel further oscillations; this method to cancel is used to allow use and control in a scene. Set: onDur (DUR) to seconds switch will, after sending DON, wait to CMD DOF. offDur (GV0) to seconds switch will, after sending DOF, wait to send DON. range 1 - 99999 seconds which gives you more than 24 hrs for each On / Off if either timer <= 0, it will be reset to 1 Status: Off(0), On(1), onTimer(2), offTimer(3) When plugin is stopped, if ST is onTimer, ST set to On for persistence. When plugin is stopped, if ST is offTimer, ST set to Off for persistence. Using Thread timers to fire switch, so for now I am not showing a status of how long left in the timers. Trying to keep a low overhead. Edited 3 hours ago by sjenkins Quote
Guy Lavoie Posted 3 hours ago Posted 3 hours ago Interesting that you bring up timers. In fact this was one of the first subjects I posted about when I first got started with a ISY994i just over a year ago. Where are the timers? I also come from a PLC world with ladder logic, and my first home automation controller was the Applied Digital Ocelot, which has timers that can be treated just as variables. I found out that you can create timers in IoX with a variable that increments after waiting 1 second, but this isn't as clean, and the unpredictable order of execution of IoX programs (which is also contrary to proper PLC logic) makes that a bit less reliable for short intervals. Forward about 6 months later (and much learning) I started learning about plugins and although the documentation is very sparse, I managed to create a simple plugin that I called Timers, that replicates the functionality of the Ocelot timers. Just as many of us name state variables with s_xxx and integer variables with i_xxx, I name my timers with t_xxx so that they're easily recognizable in programs, but are otherwise useable like variables. They certainly have been useful. Here is a screenshot of what they look like: Just like with the Ocelot, I made mine increment once per second of they're set to a non-zero value. They're handy for stepping through time separated steps of macros, and aren't subject to early termination like Wait statements (because of the triggering event no longer being true). If I only want a simple time interval, I can set one to a negative value. For example set it to -5, and five seconds later it will roll over to 0 and stop automatically. Here is an example of how I use one for the ubiquitous bathroom fan timer application: If 'Timers / t0_toilette' raw data 0 > '$i_toilette_temps Raw' Then Set 'Timers / t0_toilette' Raw value 0 $i_toilette_temps = 0 Set 'T2 Toilette Fan' Off Else - No Actions - (To add one, press 'Action') Now that we have an actual person who produces distributed plugins recognizing the need for timers...we're getting there! If you can make generic variable-like timers, that would be a great addition! Quote
sjenkins Posted 16 minutes ago Author Posted 16 minutes ago (edited) @Guy Lavoie, you made me smile ; good to have a kindred spirit out there. ( was once a controls engineer, from Canada, born in Montreal) So these ones have the added advantage of being able to be part of a scene. So your above program could be replaced by a scene. ========= Toilette Fan Scene Toilet Fan (responder) Toilet Fan offDelay(control) {switch and/or motion device which starts the fan} (control) with Toilet Fan offDelay DUR set (either manually or with a program) to how many seconds to keep on (600 if you want to be conservative for a 10min clearing of the air) =========== OR: you can use it in a program like your example above but after you switch on the offDelay the prog is: if: Toilet Fan offDelay is switched OFF then is: Set or Switch Toilet Fan OFF ============== would need a simple program to fire the offDelay: if: {switch and/or motion device which starts the fan} switch ON then: Toilet Fan offDelay switch ON ============= As I mention in the docs, I did not include a variable which tracks the countdown. Much more overhead than the Threading Timer structure. These three should cover 90% of use cases. Open to talk about those 10% though. Using these devices I have started replacing the variables and programs which simulate timers across my house. I am about half way in and have wiped out dozens of them. Helps with readability & maintainability. Edited 14 minutes ago by sjenkins Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.