Running Rule When Vac Hasn't Cleaned in X Hours - Possible Feature Request: Set Variable to Current Time/Date Int and Compare Int Function

I have a Samsung Robot vac that I can schedule (natively) to run at X time daily. The flaw here is that I’d prefer it run while I’m away…if that happens (I work from home - even pre-COVID), but need to force it at some point (even if I am home).

I started creating rules for this but ultimately I need to know if the house hasn’t been vacuumed in X hours. I can see the state of the vac, and if it stays “charging” for 18 hours (for example) run through the other criteria. This would work except any deviation from normal (briefly including turning off the power to clean the filter, a weekly job) throws that off as the value changes.

So I started thinking I could compare the last time one of these rules ran (since none of the properties I can get to from Sharptools definitively say that the unit is done with a cleaning) by writing that to a variable.

Problem 1 is that the only thing I’ve found that has anything like the current time is my Ecobee, and I can’t get to that key in order to set it as a variable. If Sharptools could have a global variable (for example) that always showed the time/date, or a variable type with the current time (from which I could select a format), that would help.

Problem 2 is that even if I have the time set as a variable, and I use that to “timestamp” when the vac runs, I don’t have logic to compare one time to another.

Another possible solution would be rule logic to determine if something has stayed X for X time. In other words, I can now look for stays state == charging for 8 hours, but I can’t look for stays state == charging for 8 hours in past 10 hours.

I know this one is complicated, so I am hoping someone has a better idea than I do, as the user story is pretty reasonable:

As the resident I want to the vacuum to run if it hasn’t completed a cleaning in the past X hours.


@William_Hirsch, supporting date and datetime in variables is in my list, along with the variable comparison functions, so your feedback with detailed use case would definitely help us in the design, and I liked the idea. Thanks!

However, just to throw an idea, you may be able to create a couple rules and variables to know when the vac hasn’t cleaned in x hours. (Again, not ideal, but just a thought.)
Rule 1:

  • Trigger: when vac status changes to “cleaning”

  • Flow: set boolean variable $cleanedIn8Hours to true, and variable $vacRunCheck to false. Wait for 1 second, and set $vacRunCheck to true

Rule 2:

  • Trigger: When variable $vacRunCheck value stays true for 8 hours
  • Flow: set $cleanedIn8Hours value to false.

Now you can use this $cleanedIn8Hours variable as the trigger (when changes to "false’) to kick off the vac, or a condition in a timer scheduled rule to check if the cleaning should be skipped or not.

1 Like

Thanks. I made a few tweaks to the logic (for example, looking for the cleaning state to have been cleaning for X mins to avoid false triggering for moving it, short jobs, etc), but I think this will work.

I was actually working on something similar to this using virtual switches b/c apparently I still forget there are variables. :slight_smile: That was my old trick for a lot of things, a ton of virtual switches used as booleans.

Much appreciated…again!