Is this a bug/glitch or am I missing something

I have a rule that monitors a portable AC unit in my shop office. The AC unit is powered thru a Zooz Power switch. The power switch is not used to control the unit only to monitor power. I control the unit with a Harmony Hub thru IR. So twice in the last few days I got a message that the AC unit did not shut down when the set temp was reached.

It just happened again an hour or so ago. I have some time this morning so I just went over the logs and code to make sure I had not missed anything. This rule is a legacy rule that I updated to 5.1 sometime after 5.1 came out. So during the winter I think, and this is the first time it's controlled the AC unit since I re-did it. It is, however, just a re-write of a rule that has been working for well over a year. From looking at the logs the rule logic does not seem to be the issue,

Below is the section of code that is running and where I see the issue. The IR command to turn the unit on and off is determined by a virtual thermostat. The rule is triggered by the operating state or mode of the thermostat changing. The operating state changing from cooling to idle is what triggered the rule. So this section of code was ran.

The log from that section is posted below. At 9:09:04 the rule was triggered. First it checks if the trigger was due to the thermostat being changed to heat mode which it was not, so that was skipped. Then it checks to see if the state is cooling and if the Zooz power switch is off. This is again not true so this was skipped.

Then there is a 5 second wait for event, to make sure there is no other triggers. At 9:09:10 the first line of this section of code was reached. The state is idle so this IF statement is executed. It first waits for up to 30 seconds for the Zooz power to go below 15 watts.

This AC unit pulls about 1000 watts when the compressor is running and about 30 watts when the compressor turns off and just the fan is active. This is a portable unit and if it reaches it's own internal setpoint it shuts down the compressor but the fan never turns off. So the harmony hub sends a IR off command which turns the unit off and it then pull less a watt.

As you can see in the log it was pulling .768 watts at the first wait, which means the unit was off. It shows in the log that it did not wait as the wait for expression was true. I then check the power again in case it timed out. If it does time out then the power will still be above 15 watts. In this case, however, it should be .768 which means it should skip the rest of the IF.

In the log it shows the power level at 24.163 watts which then sends me a notification letting me know the unit did not shut down properly. Which it did send me the notification. It then waits to make sure the compressor turns off and then turns off the power switch. AT that point it sends ma another notification letting me know that the Zooz power switch was turned off. Which it did without waiting as it again showed the power level back at .768. I did get another notification about the switch being turned off.

Below the log section I posted a screen shot of the event log from the power switch. You can see at 9:09:05 the power was 24.163 and then went to .768 at 9:09:10. That was after the point that the unit received the power off IR commend. So for some reason the the rule did not use the current power level for all of the power readings comparisons.

Just wondered if anyone sees anything that I am missing. This is apparently not happening every time as it is quite hot now and the AC unit is being cycled many times during the day. So if it were happening every time I would be getting these notifications a lot more. I could change the rule to check if the first wait timed out instead of checking the power again, but I think what I have should be ok.

very often after therms go idle the ac units run for a little while to cool down.

this may be what was happening.. the therm said idle but the fan was still running.. my acs do that..

This one does not, once it receives the off command it shuts off. That is also why I have a 30 second wait, just to make sure the command doesn't have any delays from the Harmony Hub. Also it really doesn't matter what the AC unit does it matters what the Zooz power switch reports. It reports that it's power usage is .768 watts but the rule uses the previous power reading when I recheck it after the wait. That doesn't seem right to me.

It's not the rule, it's the device report. The rule pulls up device.currentPower when it checks the conditional. So, for whatever reason, that's what came back from the device driver, even though it reported a lower value both before and after.