Time expressions evaluate differently in HE WebCoRe?

Greetings. I’ve just moved from ST to HE, and except for a few inconveniences, everything is going great. About 90% of my WebCoRe automations are moved to simple or 5.1 rules, but a few seem more difficult to convert. Of the remaining WebCoRe pistons, all are working, except one.

I have a certain blind that needs to be closed for a certain amount of time during certain months of the year when the sun’s angle is problematic, during a fixed schedule (that does not change with DST).

On ST, this expression worked perfectly:

image

On HE, the expression: evaluates to:

(expression) time(“00:01”)+time($localNow-$utc) »»» (long) 60000,

reporting (long) - whatever that means, and returning time value of just “00:01”, so it just opens at 1 minute after midnight local time. It fails to calculate:

(expression) time($localNow-$utc) »»» (time) 0,

incorrectly returning (time) 0, instead of time difference between local and utc, which calculates correctly in WebCoRe for ST:

(expression) time($localNow-$utc) »»» (time) -25200002

I thought it might just be that HE version doesn’t like negative time value, but

(expression) time($utc-$localNow) »»» (time) -1

also calculates incorrectly.

I know there are other ways to do this, but hoping someone can educate me on why this expression not working the same on HE as it does on ST. Please help.

(Already learned $twc doesn’t exist on HE and had to set up Openweather to set my “it’s cloudy” virtual switch in another rule).

$localTime = $utc on Hubitat, there is a work around but I’ll have to search for it…

Thanks. Indeed $localNow = $utc.

on HE:

(expression) time($localNow) »»» (time) 41099000 (incorrectly reports GMT)
(expression) time($utc) »»» (time) 41107000

on ST:
(expression) time($localNow) »»» (time) 15996906 (correctly reports local time)
(expression) time($utc) »»» (time) 41204750

Should have checked that first!

Just tried using time($time), and although $time correctly reports local time, time function improperly converts it back to GMT:

(expression) $time »»» (string) 11:42 A.M.
(expression) time($time) »»» (time) 42120000

It seems problematic, since webcore uses local time to trigger actions.

Do I always have to use + $tzOffset whenever I want to use any kind of time calculation, or am I missing something?

I’m still looking to see how I handled that in the past, but if @nh.schottfam is on he’ll probably be able to answer that before I find it.

Thank you for the tip on $tzOffset.

I think I can just replace ($localNow - $utc) in my piston with $tzOffset, and it will work as expected, assuming $tzOffset changes appropriately when DST ends.

It works (at least until DST change). Thanks, again.

1 Like

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