Doing something once a day, but not more, if at all

Hi Guys,

I have a rule that governs an air-to-air heat pump selecting heating or cooling with certain temperature settings etc depending on the weather outside and the temperature inside. On summer days this usually means cooling the house during the day.

I also have a rule where Alexa asks me if I want to open a window when the teperature outside turns lower than the temperature inside, which usually occures in the evening. Opening windows helps cooling the house down faster. But I only what that message to fire once at the time when the outside temeprature passes below the inside temperature which usually occures once a day during the sommer month.

My first thought was to have a local bolean set to true if the message had fired in combination with using date variable on fiering to sompare with todays date to se if the rule had fired that day. It is not unlikesly that I am missing something obvious here or complicating this rule in an unecessary way, but it turned out that was not so easy. It does not seem to be able to compare two date variables (Se screen shot below)?

What am I missing? How would you have setup the rule described above, i.e. to get a rule to fire when the outside temp passes below the inside temp and only then and only once a day, if at all? If your solution would include dates, how would you go about comapring the dates?

Cheers,

Here is a rule that I use to start the robot vacuum whenever the house mode goes to away, but it will only run once a day by using 2 different local variables. Check it out and see if you can get yours to work, ask any questions you might have if you can't figure it out. (I'm at work right now on my break)

1 Like

Your boolean idea is fine, but I would just create a separate rule that resets the boolean at midnight every night. I have one rule that runs every night to handle several tasks like this.

3 Likes

I'd keep this fairly simple of the message rule with just using a Private Boolean. The key is when to set it true again so that message can run. Assuming you only want the message to run in a cooling scenario, something like the following would work:

Trigger:
Outside Temp is lower than Inside Temp (only if Private Boolean is True)
Outside Temp is higher than Inside Temp (only if Private Boolean is False)

Action
If Private Boolean is True,
Set Private Boolean to False
Alexa Message
Else
Set Private Boolean to True
End-IF

Basically, once the temperature outside goes below your inside temperature, the voice message will run. The next time the rule will run is when the outside temperature is warmer than the inside temperature. This will reset the rule (usually sometime in the morning) and be ready to run that afternoon/evening.

1 Like

No need to reset every night with a separate rule, each time my rule runs, it sets the today variable to todays date, then it compares to the last run date (Cleaned Date in my example), if they don't match, the rule has not run today and do what needs to be done. At the end of the rule when you did whatever you needed to do, set the last run variable to today, this will insures you will not run again in the current date.

3 Likes

Thanks a lot @nclark , @dylan.c and @JB10 ! All of your solutions sovles my problem (and gave me ideas for other rules). Brilliant!

3 Likes