I have been using wakeupramp to get me up since I got Vera. I haven’t used an alarm clock since and good riddance. Now I have a bed occupancy sensor and would like to have Vera run a scene if I haven’t gotten out of bed a certain amount of time after my wakeupramp scene started. What kind of code would I need to cook up to make this happen?
I wish this simple kind of thing were easier to get going.
Make a scene and schedule it to run every 5 minutes. Make this scene do whatever dastardly thing sleeper-innerers do. Add this Luup code:
local started = luup.variable_get("some-unused-namespace", "Started", 123) or "-1"
if (tonumber(started) == -1) then return false end -- No wakeup ramp running.
if (difftime(os.time(), tonumber(started)) < 900) then return false end -- 15 minutes grace.
luup.variable_set("some-unused-namespace", "Started", -1, 123) -- Reset for tomorrow.
return true
For “123”, substitute a suitable device ID from your house (say, the Wakeup Ramp device). It shouldn’t matter if you are consistent.
This is a bit more kludgy and doesn’t have to-the-second accuracy, but it should work.
I have some questions on the code. I have a scene called “Weekday Wakeup” which starts wakeup ramp at 4:15. I add the first line of code and I replace 123 with the wakeup ramp device ID (13). What do I use for “some-unused-namespace”?
I I then create a scene which is triggered by me getting out of bed and add the second bit of code replacing 123 with 13 and then I replace “some-unused-namespace” with…?
Then I make a scene which runs every 5 minutes (is that really necessary?) which will send TTS to Vera Alert that gives me some hell for sleeping in and I again replace 123 with 13 in the two locations. In this bit of code how is the time from triggering to running determined? Is the <900 involved here? 900 seconds is 15 minutes.
So I’m experimenting with the countdown timer. I have a scene which activates the wakeupramp. I have it also activate a timer. I have a scene which barks at me when I don’t get up after a while. I also have a scene which turns the timer off if I get out of bed. The problem is that this scene will run every time I get out of bed. So it will run if I get up from a nap. Or if I get off the bed after making it in the morning. Is there a way to specify that it only run between 4:15 and 5:15?
The customary no-Luup way that I recommend is to use a Virtual Switch, set scenes to turn it on at 4:15 and off at 5:15, create a Combination Switch that watches the Virtual Switch status, and change your existing scene to press the “Trigger” button on the Combination Switch. Your event then becomes “Triggered while Virtual Switch is on”.
I now have two timers. One runs a scene in which Vera Alerts kindly and reasonably reminds me to get out of bed. The second completes 20 minutes later and swears at me and generally gives me hell. Getting out of bed cancels both timers.
I have the day off today and decided to sleep in. I found a flaw in my setup. The wakeup ramp ran as usual for weekdays and then my two timers started (one to gently remind me to get up and one to really nag me if I persist in sleeping). I had disarmed the bed sensor before going to bed but I still get yelled at. Pretty bad WAF. She had no issues with expressing her doubts about the system. Is there a way I can have the wakeup ramp not run if the bed sensor is disarmed or if there is a signal from the Google calendar plugin? There must be some LUUP code I can toss in my weekday wakeup scene which doesn’t activate it if the sensor is disarmed.
There’s a hidden “inhibit” field in the Wakeup Ramp settings that prevents it from starting if a switch is turned on. IIRC you have to put it into the Advanced tab as a variable and specify the device id of the switch.
Then it’s a matter of creating the switch. A Combination Switch will do the job, and you can hopefully set its conditions the way you want. I think Google Calendar events come through as security sensors.
Yes. I got the combination switch working with Google Calendar so WakeupRamp doesn’t start on days I don’t work. So I origingally had a scene which started wakeupeamp and then started my two timers. I could inhibit wakeupramp with the combination switch but not the timers. So I removed the timers from the wakeup scene, created a new scene called work day wakeup and have that start the timers when wakeup ramp starts. One problem. When inhibited wakeupramp does start for just a moment and is immediately shut back off. The result is that the lights never come on but the timers do. Is there a way to similarly inhibit the timers?
BTW futzle, there seems to be a bug with the countdown timer. When I set it in the UI for scene creation is stays greyed out but does indeed operate. The result is that when going back and looking at a scene I can’t tell if it’s set or not. Also you can’t remove it from a scene. I had to scrap my weekday wakeup scene and start from scratch.
Huh, that complicates things. I bet you could add more epicycles to the system, and have a two-second timer watch the Wakeup Ramp status. If that completes without being cancelled then the Wakeup Ramp must have started Properly, and then you can start the timer you already have.
(There’s a saying in programming that all problems can be solved by adding another level of indirection. Except for the problem of too many levels of indirection. This might be one of those cases where it’s better for your sanity to do it all with some custom Lua.)
BTW futzle, there seems to be a bug with the countdown timer.
Yes, that gets reported in the Countdown Timer plugin thread once or so a month. It’s a UI bug in Vera’s JavaScript, something I can’t fix. I reported it to MCV months ago.
Use the Advanced scene editor tab and you can edit and delete the scenes as expected.
Damn! Another timer?! Well, a man’s gotta do what a man’s gotta do. I’ll make a 2-3 second timer to start the other two timers.
Good idea about removing/checking on the timers from the advanced tab. Don’t know why I didn’t think about that. This image oriented UI is making me stupid.
Will report back.
EDIT:
This is getting confusing.
EDIT 2:
OK. F this. Is there a simple LUUP way to simply not run my morning wakeup scene if the google calendar is tripped?
EDIT 3:
Maybe one of the RTS plugins could do this all?
I think you’ve got your logic backwards there. The “return true” clause means “start the timer”. Perhaps you want:
if ((...) and (...))
so that the timer starts only if you haven’t got out of bed AND it isn’t a holiday. Depends on how you’ve defined Tripped for your bed sensor: occupied or unoccupied.
There are only about four possibilities, so you could find out the right answer exhaustively if you didn’t want to do the logic from first principles…
Well, it seems to be working quite well. I haven’t had a weekday off since implementing the new code but I have created dummy entries in the calendar and the scene doesn’t fire if I’m not in bed and it’s still waking me up in the morning and harassing me. With the “or” the scene was dead in the water for some reason.
This is a blast.
Thanks for all the help futzle.
Best Home Automation shopping experience. Shop at Ezlo!