Counters

I have a morning wakeup routine that turns lights and tv on. It is based on a schedule and motion in the hallway during the hours specified. I want it to fire only once in the morning. Can counters be used to do that? I have read all of the info on Counters in the forum but am still unclear how to use them in Conditions or Actions. Does anyone have an example of a counter being used in such a way?

I don’t think I would use counters for this. Just really a sequence expression comparing timestamps. Here is one I use after a little simplification - sequence expressions are the ones in parenthesis with semi-colons. Essentially I refer to the timestamp that the light previously was turned on or off, to make sure it has not already turned on or off during the period in question (here VeryDark).

Condition: BedroomNeedsFanLightsOn

Expression: BedroomOccupancy and VeryDark and !BedroomFanLightsOn and (!BedroomFanLightsOn; VeryDark) and (BedroomFanLightsOn; VeryDark)

So only turn the lights on if:

  • There is movement in the bedroom
  • It is dark (PLEG schedule VeryDark from +00:20:00t to r)
  • The lights are off
  • The lights were last turned off before it became dark
  • The lights were last turned on before it became dark

You might see the last two as redundant, but I wanted to be real careful on this one not to turn on lights when someone might be asleep in bed and just rolled over, triggering the motion detector. This will just fire once a night, and only in certain situations (some of which I removed for readability).

Thanks! That got me to thinking about my logic. I turn on two lights in the morning. So I added logic for the condition to fire only if the lights are off.

BTW, if you had devices in the action that are not devices directly within Vera, or if there are several, and hence it is hard to check to see if “lights on”, then you could use the same logic but reference the last timestamp of the condition itself instead of the timestamp of a device.

So if Condition like: MorningNeedTVandCoffee then Expression like: Morning and Motion and (MorningNeedTVandCoffee; Morning).

So only run if morning and there is motion and it has not already run since it became morning. The trick is you have to get the condition to trigger the first time, and when you first build it the timestamp will be NULL and won’t be able to evaluate the sequence expression. You can start by building the expression with something that will evaluate as true to get a timestamp populated, then modify the expression to what you want.

My TVs are controlled via LUA and are not Vera devices, so this would be how I would want to trigger a morning routine like that…