bstrebel/pimatic-phone

pimatic-phone based Rule fires when pimatic starts

SenTzu01 opened this issue · 4 comments

Hi Bernd,

First of all thank you for your efforts, I am happily using the phone plugin, which usually works like a charm!
Since yesterday after fiddling with some rules I cam across what I think is a bug.
Steps to reproduce:

  1. Install pimatic@0.9.37 (stable) and pimatic-phone@0.4.2
  2. Setup an iPhone device in pimatic-phone
  3. setup a home location tag in pimatic-phone
  4. Create a rule with the condition as below
    when $my-iphone.location changes and $my-iphone.location = "Home" then turn on switch-livingroom-av

Expected behaviour:
Execute rule only when device location gets updated to "Home" (Previous location <> "Home")

Actual behaviour:
Expected behaviour but the rule is also executd when pimatic starts. Right before the rule execution is logged, in the log I see the following:

info [pimatic-phone]: Found device "iPhone" for xxxxxxx@xxxx.com
info [pimatic-phone]: Found device "iPad" for xxxxxx@xxxxx.com

Update:
After creating a rule to dump the $my-iphone.location attribute at system start I noticed:

12:49:07.400 [pimatic] rule set-iphone-location-at-system-start: set $iphone-location-at-start to undefined

Could you look into this? Perhaps a solution would be to make the state peristent across reboots?

Dan

Nice to hear that someone else is using the new plugin. Since my pimatic is running almost 24x7 and I thought it's not necessary to take car on the most probably outdated state of the phone. I will have a look the startup initialization next week.

Thanks, thats great (And thanks for your efforts, you have a happy customer) !
I have also found the rules get executed when the iPhone device configuration is updated in the GUI and then recreated by Pimatic.

Meanwhile I found a workaround by creating a variable, then using a rule

when $my-iphone.location changes and $my-iphone.location != $my-location then set $previous-location = $my-location and set $my-location = $my-iphone.location

I have also noted the value of $previous-location becomes NULL after Pimatic restart, which hints at your explanation for the cause being correct :)

subsequently I use $my-location in my rules. This seems to do the trick, but still have to test if this allows me to correctly execute rules on intended location changes of the mobile.

@SenTzu01 pls. update to Rev. 0.4.3 and let me know if this works for you.

Just updated and could no longer reproduce the scenarios, awesome!
Thanks for your help !!