# Is the month of year as a number available for comparison?

I am writing a rule to test my WaterCop valve every 2 months. Because of the long time between events I would like to monitor it with another rule. My approach is:

Create a global variable initialize it to the month value (i.e. February = 2)
at each test increment the global by 2

In another rule, compare the above global to the month of the years.

I would need to know the month as a number to do this. Is the month number availiable?
If not thoughts on a different approach?

Thanks
John

Preface - I haven't tried this.

You should be able to use Periodic Trigger and enter an "explicit cron" to just run it every other month at a specified time/day.

For instance, every month on the 1st, at noon would be:
0 0 12 1 * ?

Lots of cron calculators out there. Here is one I use a lot:
https://www.freeformatter.com/cron-expression-generator-quartz.html

Or maybe 1st of the month @ 1am every other month:
0 0 1 1 1/2 ? *

1 Like

I'm not sure if there is a way to dump just the day or month portion of time into a variable in RM.

EDIT: You could set a variable to now() (in seconds, millis is too much I think and will overflow) when the test happens. Then at some frequency (1x/day?) in another rule do math based on the delta of the current now() and the old variable. If > than the max you want, then do actions.

That's OK with your suggestion I can simply parallel the "watch rule" and compare global. I'll have to continue thinking if the is using the same resources to a degree that if one fails the other might likely fail

Yeah, using variables and current time works.

I set global variable nowTime2 in this rule every 1 minute - type number, current time in seconds. This would be the 'valve test' rule.

Then this rule runs every 15s and checks to see if is has been >10 seconds since the other rule ran by checking current time. Which obviously it will be 3 out of 4 times as the other rule only runs 1x/min. In a real rule you would want to do something more productive than setting the rules own Private Boolean false/true.

Might be an easier way to do it, but this works.

@JohnRob know your watercop is newer than my ATT version but wanted you to be aware that every time I reboot my hub, the valve looses connection. Basically no commands to the valve work. I have to cycle power on the valve to reconnect. I installed a smart switch that the valve is plugged into and a rule that fires on the system start event to cycle power. Again unsure if your newer model has this same issue but I wanted to throw this out there for your awareness and suggest you test it.

1 Like

Thank you for your warning. I will admit my BP increased a bit while the hub was rebooting. Boy it takes a long time to reboot when your anxious.

The good news is this unit reconnects after a boot. No issues here

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.