I don’t have many rules, actually only 1 for now. I have a day-light lamp beside my bed and I am a heavy sleeper and use the rule to turn the lamp on at the same time my alarm goes off and it helps greatly as my room is quite dark when I need to be awake. I use the IDE to create the static rule and it works great, except for one thing…the weekends. I know I can set as many different times and days, etc. as I want if I hard code it into the rule; however, this isn’t quite as flexible as I need it to be.
For instance, I am an IT Operations corporate lead for a large enterprise, which means many nights I am woken up or have to stay up late due to problems at a location overnight. Well, if I don’t get in bed until 4AM, I am not going to be waking up at 5:30 AM and will sleep in. Problem is, if the rule is hard coded, the only way I can really get the light to not turn on is to either a.) log in and change the time, b.) turn the lamp off manually so that even when the RF Outlet turns on, the light doesn’t (downfall here being I won’t have a light turn on when I need it to).
So, I was thinking it would be fantastic if we could change the rule time (essentially akin to an alarm setting on the phone) directly from the Android (or any) app. Is this possible currently?
Anything is possible, but this is one of the use cases that is a little awkward to implement in OH.
One solution could be the Alarm example:
Set up a simple delay function. The logic gets a little convoluted but basically you would set up a Switch which triggers the “alarm”. Your cron driven rule would send a command to this Switch immediately only if the Delay Switch isn’t ON. If the Delay switch is ON then set a timer to wait to trigger the Alarm switch a certain number of hours. You can even use a Number Item and a SetPoint or Slider to specify how many hours to delay. Finally make sure to reset the Delay Switch to OFF when the Alarm does go off. This could be combined with an IFTTT Do button mapped to setting the Delay Switch to ON. Or if you are on Android with Tasker you can create a simple widget. If you have reliable presence detection, you could automatically trigger the delay if you return home after a certain hour.
Hey thanks for the reply Rich. Hadn’t had a chance to digest it until now. I agree that it seems a bit convoluted for sure. I feel like this would work, and may attempt the implementation. Although, my oldest son is a Java developer, so perhaps I can work with him to build something that may work better.
If we could do cascading .rules pages, this would be quite simple to do, I would imagine. Essentially just set an alarm as you have mentioned, but in doing so, java can be used to create, delete, change, etc. the simple on/off command based on whatever time is entered. Don’t think that is an option at the moment, though a compelling argument for the ability to cascade rules.
You can do cascading rules. I’ll try to find the posting where I wrote on example fur someone. It was for an irrigation controller so one zone would start after the last one finished.
The real problem we have in OH 1 and the current version of OH 2 is that there is no way to dynamically schedule an event to trigger a rule easily. I can use Astro 1.9 or the alarm clock examples, but there is no direct and simple easy to have an really scheduled event to trigger a rule.
I do say the current version of OH 2 deliberately because there are changes in work to redo the sheet of thing the Astro binding does which might solve this problem. Steady tuned.
Thanks for the update. Actually, I have intimately gotten to know the alarm function over the past few hours…I will say, this does exactly what I was looking for actually and it works very well! Though, the implementation is a bit clunky and there are a couple of bugs (not sure if mine or OH in general) however, as far as I can see this will do.
For those curious, the bugs are minor. For some reason, my Tuesday item doesn’t have a lightbulb icon and I am not sure why. It is just blank. Also, when I change the time, it does not seem to work on the IPhone app, though it will change the actual time on the server, but only by 1 step one way or the other but does not update the displayed time. I figured this out by watching the web page on my laptop while changing it on the phone. I read about a but with this element on the iPhone but it was closed, stating removing the parenthesis from min, max, and step but this was a workaround and apparently no longer works.
Luckily, I also have an LG V10 and this problem does not exist on the android app. I use my V10 about 95% of the time anyway so shouldn’t be any issues. Thanks again ffor the help!