Wizzard72 / Domoticz-Unifi-Presence

GNU General Public License v3.0
5 stars 7 forks source link

Set delay for device offline? #13

Closed blaxxor closed 3 years ago

blaxxor commented 3 years ago

Hi!

Is there a possibility to set a delay for a phone to be "Off"?

Here is the log for my phone. As you can see the phone seems to do a quick disconnect from time to time and it sets the IDX of the phone On and Off a lot. Is it possible to insert a value that if the ID is Off for 60s then set the IDX as Off?

I think the drop happens when my controller move the phone between my APs. It's never noticed on the device but it's logged in the controller.

I tried using the "Off delay" under devicesettings but that doesn't seem to make a difference.

2021-03-25 21:27:45 | On 2021-03-25 21:27:20 | Off 2021-03-25 19:13:45 | On 2021-03-25 19:13:40 | Off

Regards.

Wizzard72 commented 3 years ago

I take a look at it and see how to implement this in the code

blaxxor commented 3 years ago

Any ideas yet how to solve this? :)

Wizzard72 commented 3 years ago

No it's quite difficult. I see it sometime also. The plugin creates a table with the statuses. The Unifi controller or dreammachine is queried every 5 seconds. So how to combine all of this. It's easier to use a second check. For example I use geofencing. If my phone is near my house it toggle a switch (also part of the plugin). This ensure that the plugin knows that I'm home.

I'm not a developer, so with trial and error I created this plugin. If you have a solution it's more than welcome.

blaxxor commented 3 years ago

Well, I see it a lot :) 33 times yesterday it logged on an off.

Unfortunately I'm not a programmer either. But at some point in the code the phone gets its status (On of Off). Isn't it possible to do something like

if (phone1 == Off for 1 min) set DeviceID == Off

Do you know on which line the device sets the status?

Wizzard72 commented 3 years ago

Pushed a new version 2.9.0 with Off Delay option in it. The plugin creates a new selector switch where you can select the off delay in seconds.

blaxxor commented 3 years ago

I upgraded yesterday and it seems to be working just fine now. Thanks for a great solution :)