Odianosen25 / Monitor-App

Appdaemon App for Andrew's Monitor Presence Detection System
74 stars 9 forks source link

Everyone_home/not_home wrong state #58

Open pointlevel opened 4 years ago

pointlevel commented 4 years ago

Hello!

I have started to looking to use the binary sensors created from the app. But my sensors are reporting wrong state. In the app i have 4 macs. And by the time writing, 2 is home and 2 is away. And the status of the sensors is:

binary_sensor.everyone_home = on
binary_sensor.everyone_not_home = off

Feels to me that they are switched?

Odianosen25 commented 4 years ago

Hello @pointlevel,

Yeah I just saw it, and weird I didn't see it before. Though @skynet01 had reported it before, but seems my fix not as solid as I thought.

Will see if its something I can fix over the weekend.

Regards

pointlevel commented 4 years ago

Now a couple of hours later the sensors is different(correct) with same number of people in the house(actually also the same people), se below:

binary_sensor.everyone_home = off
binary_sensor.everyone_not_home = off
Odianosen25 commented 4 years ago

Yes @pointlevel,

It’s the same bug reported. Initially it’s wrong, and after a while it’s head gets settled. I just need to find a reliable way to fix it, still no clue yet.

Regards

skynet01 commented 4 years ago

While we are on the subject of these variables it looks like they are being reset when HA restarts and then updated once scan is complete. This results in some automations being fired incorrectly. Here is my case scenario:

  1. people are home - binary_sensor.somebody_home = on
  2. -- HA Restarts --
  3. binary_sensor.somebody_home > gets set to off. > automation is fired because no one is home
  4. scan starts, people are found again
  5. binary_sensor.somebody_home > gets set to on > automation is fired because someone is home

I believe a solution is to preserve the state of these variables during restart and only update them after the scan is finished (if it's not already like this). Currently i had to add delays to my automations just to compensate for this.