Python plugin: Ubiquiti Unifi Presence

Python and python framework

Moderator: leecollings

wizzard72
Posts: 116
Joined: Friday 20 December 2013 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by wizzard72 »

David82 wrote: Thursday 07 January 2021 9:41 I think there is a probleem with de login command.

with correct login data I get this:
2021-01-07 08:07:48.277 Status: (UniFI) Started.
2021-01-07 08:07:49.313 (UniFI) Debug logging mask set to: NONE
2021-01-07 08:07:49.313 (UniFI) setVersionCheck - Plugin allowed to start (triggered by: onStart)
2021-01-07 08:07:49.313 (UniFI) Number of icons loaded = 3
2021-01-07 08:07:49.313 (UniFI) onStart: Items = UnifiPresenceAnyone
2021-01-07 08:07:49.313 (UniFI) onStart: Icon 101 Name = UnifiPresence
2021-01-07 08:07:49.313 (UniFI) onStart: Items = UnifiPresenceOverride
2021-01-07 08:07:49.313 (UniFI) onStart: Icon 102 Name = UnifiPresence
2021-01-07 08:07:49.313 (UniFI) onStart: Items = UnifiPresenceDevice
2021-01-07 08:07:49.313 (UniFI) onStart: Icon 103 Name = UnifiPresence
2021-01-07 08:07:49.309 Status: (UniFI) Entering work loop.
2021-01-07 08:07:49.310 Status: (UniFI) Initialized version 2.5.0, author 'Wizzard72'
2021-01-07 08:07:50.475 (UniFI) detect Unifi Devices: Invalid login, or login has expired
2021-01-07 08:07:50.476 (UniFI) create_devices: Found phone to monitor from configuration = Phone1=00:11:32:18:B0:XX
2021-01-07 08:07:59.998 (UniFI) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-07 08:08:00.885 (UniFI) onHeartbeat: Requesting Unifi Controller details
2021-01-07 08:08:00.906 (UniFI) request_details: Invalid login, or login has expired
2021-01-07 08:08:00.927 (UniFI) request_online_phones: Invalid login, or login has expired
2021-01-07 08:08:00.927 (UniFI) ProcessDevices: Total Phones connected = 0
2021-01-07 08:08:05.439 (UniFI) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-07 08:08:06.204 (UniFI) onHeartbeat: Requesting Unifi Controller details
2021-01-07 08:08:06.224 (UniFI) request_details: Invalid login, or login has expired
2021-01-07 08:08:06.243 (UniFI) request_online_phones: Invalid login, or login has expired
2021-01-07 08:08:06.244 (UniFI) ProcessDevices: Total Phones connected = 0

with the incorrect login
2021-01-07 08:08:44.504 Status: (UniFI) Started.
2021-01-07 08:08:45.538 (UniFI) Debug logging mask set to: NONE
2021-01-07 08:08:45.538 (UniFI) setVersionCheck - Plugin allowed to start (triggered by: onStart)
2021-01-07 08:08:45.538 (UniFI) Number of icons loaded = 3
2021-01-07 08:08:45.538 (UniFI) onStart: Items = UnifiPresenceAnyone
2021-01-07 08:08:45.538 (UniFI) onStart: Icon 101 Name = UnifiPresence
2021-01-07 08:08:45.538 (UniFI) onStart: Items = UnifiPresenceOverride
2021-01-07 08:08:45.538 (UniFI) onStart: Icon 102 Name = UnifiPresence
2021-01-07 08:08:45.538 (UniFI) onStart: Items = UnifiPresenceDevice
2021-01-07 08:08:45.538 (UniFI) onStart: Icon 103 Name = UnifiPresence
2021-01-07 08:08:45.533 Status: (UniFI) Entering work loop.
2021-01-07 08:08:45.534 Status: (UniFI) Initialized version 2.5.0, author 'Wizzard72'
2021-01-07 08:08:47.203 (UniFI) detect Unifi Devices: Invalid login, or login has expired
2021-01-07 08:08:47.204 (UniFI) create_devices: Found phone to monitor from configuration = Phone1=00:11:32:18:B0:XX
2021-01-07 08:08:56.726 (UniFI) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-07 08:09:02.448 (UniFI) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-07 08:09:08.314 (UniFI) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-07 08:09:14.253 (UniFI) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-07 08:09:20.174 (UniFI) onHeartbeat: Attempting to reconnect Unifi Controller

unifi controler versie 6.0.36 (Build: atag_6.0.36_14304) (raspberry)
USG-3P
Can you make a screenshot of the plugin hardware settings?
rbosch
Posts: 11
Joined: Monday 18 January 2016 20:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by rbosch »

wizzard72 wrote: Monday 11 January 2021 8:58 @rbosch, can you login into your dreammachine and then change the url into this:

https://dreammachineIP:Port:/api/s/default/stat/device
Initially I was a bit puzzled as these URLs only brought me to the login screen of the Dreammachine.
Then I realized the UDM requires the /proxy/network to be inserted in the URL.

https://dreammachineIP:Port:/proxy/network/api/s/default/stat/...

does the trick and delivers the result you are looking for.

I will sent you a PM.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by mcmikev »

Hi there,

Great concept of this plugin!! I just upgraded a while back to the UDM-Pro and tried this plugin.
I cannot get connected.

The username and password are the same I use to connect to the UDP portal/device.

Still at statup of the plugin I get 401 and then 404 errors and after a while this one.
First 404:
2021-01-12 20:23:43.304 Error: (Unifi-Presence) login: Failed to login to the Dream Machine Pro with errorcode 404
then

Code: Select all

2021-01-12 20:21:36.724 (Unifi-Presence) Pushing 'onHeartbeatCallback' on to queue
2021-01-12 20:21:36.754 (Unifi-Presence) Processing 'onHeartbeatCallback' message
2021-01-12 20:21:36.754 (Unifi-Presence) Calling message handler 'onHeartbeat'.
2021-01-12 20:21:36.755 (Unifi-Presence) onHeartbeat: called
2021-01-12 20:21:36.755 (Unifi-Presence) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-12 20:21:36.755 (Unifi-Presence) login: called
2021-01-12 20:21:36.762 Error: (Unifi-Presence) 'onHeartbeat' failed 'ConnectionError'.
2021-01-12 20:21:36.763 Error: (Unifi-Presence) ----> Line 1009 in '/home/pi/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onHeartbeat
2021-01-12 20:21:36.763 Error: (Unifi-Presence) ----> Line 404 in '/home/pi/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onHeartbeat
2021-01-12 20:21:36.763 Error: (Unifi-Presence) ----> Line 440 in '/home/pi/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function login
2021-01-12 20:21:36.763 Error: (Unifi-Presence) ----> Line 581 in '/usr/lib/python3/dist-packages/requests/sessions.py', function post
2021-01-12 20:21:36.763 Error: (Unifi-Presence) ----> Line 533 in '/usr/lib/python3/dist-packages/requests/sessions.py', function request
2021-01-12 20:21:36.763 Error: (Unifi-Presence) ----> Line 646 in '/usr/lib/python3/dist-packages/requests/sessions.py', function send
2021-01-12 20:21:36.763 Error: (Unifi-Presence) ----> Line 498 in '/usr/lib/python3/dist-packages/requests/adapters.py', function send 
Did I made a mistake somewhere or is this a bug??
Happy to help out if needed
rbosch
Posts: 11
Joined: Monday 18 January 2016 20:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by rbosch »

There was a bug - due to differences between UDM and regular Controller.
@wizzard72 made some updates and it was successfully tested on my UDM.
So if you update the plug-in (git pull and restart Domoticz) it should work.
David82
Posts: 4
Joined: Monday 21 May 2018 22:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by David82 »

wizzard72 wrote: Monday 11 January 2021 9:04
David82 wrote: Thursday 07 January 2021 9:41
Can you make a screenshot of the plugin hardware settings?
unifi plugin.png
unifi plugin.png (34.58 KiB) Viewed 2567 times
2021-01-15 22:51:13.196 Status: (Thuisnetwerk) Started.
2021-01-15 22:51:14.144 (Thuisnetwerk) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE
2021-01-15 22:51:14.144 (Thuisnetwerk) setVersionCheck - Plugin allowed to start (triggered by: onStart)
2021-01-15 22:51:14.144 (Thuisnetwerk) Number of icons loaded = 3
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Items = UnifiPresenceAnyone
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Icon 102 Name = UnifiPresence
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Items = UnifiPresenceOverride
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Icon 103 Name = UnifiPresence
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Items = UnifiPresenceDevice
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Icon 104 Name = UnifiPresence
2021-01-15 22:51:14.144 (Thuisnetwerk) login: called
2021-01-15 22:51:14.140 Status: (Thuisnetwerk) Entering work loop.
2021-01-15 22:51:14.141 Status: (Thuisnetwerk) Initialized version 2.5.8, author 'Wizzard72'
2021-01-15 22:51:15.250 (Thuisnetwerk) login: Login successful into Unifi Controller
2021-01-15 22:51:15.277 (Thuisnetwerk) detect Unifi Devices: Invalid login, or login has expired
2021-01-15 22:51:15.277 (Thuisnetwerk) create_devices: Found phone to monitor from configuration = David=cc:21:19:03:9b:7f
2021-01-15 22:51:15.277 (Thuisnetwerk) create_devices: Found phone to monitor from configuration = Evi=ae:ae:6f:90:58:24
2021-01-15 22:51:15.277 (Thuisnetwerk) onStart: Phone Naam = OverRide | 00:00:00:00:00:00 | 255 | Off | No | No
2021-01-15 22:51:15.278 (Thuisnetwerk) onStart: Phone Naam = David | cc:21:19:03:9b:7f | 50 | Off | No | No
2021-01-15 22:51:15.278 (Thuisnetwerk) onStart: Phone Naam = Evi | ae:ae:6f:90:58:24 | 51 | Off | No | No
2021-01-15 22:51:15.278 (Thuisnetwerk) Pushing 'PollIntervalDirective' on to queue
2021-01-15 22:51:15.278 (Thuisnetwerk) Processing 'PollIntervalDirective' message
2021-01-15 22:51:15.278 (Thuisnetwerk) Heartbeat interval set to: 5.
2021-01-15 22:51:24.780 (Thuisnetwerk) Pushing 'onHeartbeatCallback' on to queue
2021-01-15 22:51:24.797 (Thuisnetwerk) Processing 'onHeartbeatCallback' message
2021-01-15 22:51:24.798 (Thuisnetwerk) Calling message handler 'onHeartbeat'.
2021-01-15 22:51:24.798 (Thuisnetwerk) onHeartbeat: called
2021-01-15 22:51:24.798 (Thuisnetwerk) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-15 22:51:24.798 (Thuisnetwerk) login: called
2021-01-15 22:51:25.705 (Thuisnetwerk) login: Login successful into Unifi Controller
2021-01-15 22:51:25.705 (Thuisnetwerk) onHeartbeat: Requesting Unifi Controller details
2021-01-15 22:51:25.732 (Thuisnetwerk) request_details: Invalid login, or login has expired
2021-01-15 22:51:25.759 (Thuisnetwerk) request_online_phones: Invalid login, or login has expired
2021-01-15 22:51:30.260 (Thuisnetwerk) Pushing 'onHeartbeatCallback' on to queue
2021-01-15 22:51:30.268 (Thuisnetwerk) Processing 'onHeartbeatCallback' message
2021-01-15 22:51:30.268 (Thuisnetwerk) Calling message handler 'onHeartbeat'.
2021-01-15 22:51:30.268 (Thuisnetwerk) onHeartbeat: called
2021-01-15 22:51:30.268 (Thuisnetwerk) onHeartbeat: Attempting to reconnect Unifi Controller
rbosch
Posts: 11
Joined: Monday 18 January 2016 20:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by rbosch »

For UDM the port number is 443. And you need to make a local account on your UDM for use of the plugin.
Btw - there is still an error in the current version. After some time (on my UDM almost 2 hours) the login failed. No fix yet.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by mcmikev »

After many tests and code changing :-) it finally works like a charm on the UDM-Pro

Thank you Wizzard72 for making the plugin and quick fixes!!!
wizzard72
Posts: 116
Joined: Friday 20 December 2013 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by wizzard72 »

David82 wrote: Friday 15 January 2021 22:49
wizzard72 wrote: Monday 11 January 2021 9:04
David82 wrote: Thursday 07 January 2021 9:41
Can you make a screenshot of the plugin hardware settings?
unifi plugin.png
2021-01-15 22:51:13.196 Status: (Thuisnetwerk) Started.
2021-01-15 22:51:14.144 (Thuisnetwerk) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE
2021-01-15 22:51:14.144 (Thuisnetwerk) setVersionCheck - Plugin allowed to start (triggered by: onStart)
2021-01-15 22:51:14.144 (Thuisnetwerk) Number of icons loaded = 3
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Items = UnifiPresenceAnyone
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Icon 102 Name = UnifiPresence
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Items = UnifiPresenceOverride
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Icon 103 Name = UnifiPresence
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Items = UnifiPresenceDevice
2021-01-15 22:51:14.144 (Thuisnetwerk) onStart: Icon 104 Name = UnifiPresence
2021-01-15 22:51:14.144 (Thuisnetwerk) login: called
2021-01-15 22:51:14.140 Status: (Thuisnetwerk) Entering work loop.
2021-01-15 22:51:14.141 Status: (Thuisnetwerk) Initialized version 2.5.8, author 'Wizzard72'
2021-01-15 22:51:15.250 (Thuisnetwerk) login: Login successful into Unifi Controller
2021-01-15 22:51:15.277 (Thuisnetwerk) detect Unifi Devices: Invalid login, or login has expired
2021-01-15 22:51:15.277 (Thuisnetwerk) create_devices: Found phone to monitor from configuration = David=cc:21:19:03:9b:7f
2021-01-15 22:51:15.277 (Thuisnetwerk) create_devices: Found phone to monitor from configuration = Evi=ae:ae:6f:90:58:24
2021-01-15 22:51:15.277 (Thuisnetwerk) onStart: Phone Naam = OverRide | 00:00:00:00:00:00 | 255 | Off | No | No
2021-01-15 22:51:15.278 (Thuisnetwerk) onStart: Phone Naam = David | cc:21:19:03:9b:7f | 50 | Off | No | No
2021-01-15 22:51:15.278 (Thuisnetwerk) onStart: Phone Naam = Evi | ae:ae:6f:90:58:24 | 51 | Off | No | No
2021-01-15 22:51:15.278 (Thuisnetwerk) Pushing 'PollIntervalDirective' on to queue
2021-01-15 22:51:15.278 (Thuisnetwerk) Processing 'PollIntervalDirective' message
2021-01-15 22:51:15.278 (Thuisnetwerk) Heartbeat interval set to: 5.
2021-01-15 22:51:24.780 (Thuisnetwerk) Pushing 'onHeartbeatCallback' on to queue
2021-01-15 22:51:24.797 (Thuisnetwerk) Processing 'onHeartbeatCallback' message
2021-01-15 22:51:24.798 (Thuisnetwerk) Calling message handler 'onHeartbeat'.
2021-01-15 22:51:24.798 (Thuisnetwerk) onHeartbeat: called
2021-01-15 22:51:24.798 (Thuisnetwerk) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-15 22:51:24.798 (Thuisnetwerk) login: called
2021-01-15 22:51:25.705 (Thuisnetwerk) login: Login successful into Unifi Controller
2021-01-15 22:51:25.705 (Thuisnetwerk) onHeartbeat: Requesting Unifi Controller details
2021-01-15 22:51:25.732 (Thuisnetwerk) request_details: Invalid login, or login has expired
2021-01-15 22:51:25.759 (Thuisnetwerk) request_online_phones: Invalid login, or login has expired
2021-01-15 22:51:30.260 (Thuisnetwerk) Pushing 'onHeartbeatCallback' on to queue
2021-01-15 22:51:30.268 (Thuisnetwerk) Processing 'onHeartbeatCallback' message
2021-01-15 22:51:30.268 (Thuisnetwerk) Calling message handler 'onHeartbeat'.
2021-01-15 22:51:30.268 (Thuisnetwerk) onHeartbeat: called
2021-01-15 22:51:30.268 (Thuisnetwerk) onHeartbeat: Attempting to reconnect Unifi Controller
A lot of changes were made to the plugin. Can you update the plugin.
Also I see in plugin configuration that the username is an email address. Can you put in the Username instead of the email-address?
wizzard72
Posts: 116
Joined: Friday 20 December 2013 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by wizzard72 »

Special thanks to @rbosch and @mcmikev for troubleshooting the Unifi Dream Machine Pro part of the plugin.
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by CronoS »

I have got a question regarding the plugin. I have not used it yet, but I have used the old DZvent script for quite some time now.

My question is, I detect multiple devices using the script, this beside the phones. An example is to detect if my PC is still one after some time to get a notifcation, the same for the TV's which I use in other scripts. The reason is that I use the DZvent with Unifi, is that I do not want to ping around the whole day to multiple devices every minute. I like using the script, because when it is executed everything is detected in the same timeframe.

Now I see in the Plugin that there is a button Unifi Anyone, this is indeed the case with phones.. but I do not want to use it for other devices. Is that changable? So Is it still, for my environment, a good idea to switch over to the plugin?
David82
Posts: 4
Joined: Monday 21 May 2018 22:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by David82 »

wizzard72 wrote: Tuesday 19 January 2021 22:52
David82 wrote: Friday 15 January 2021 22:49
wizzard72 wrote: Monday 11 January 2021 9:04
A lot of changes were made to the plugin. Can you update the plugin.
Also I see in plugin configuration that the username is an email address. Can you put in the Username instead of the email-address?
no result after update an using username instead email adress.

2021-01-22 15:48:38.326 (Thuisnetwerk) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE
2021-01-22 15:48:38.326 (Thuisnetwerk) setVersionCheck - Plugin allowed to start (triggered by: onStart)
2021-01-22 15:48:38.326 (Thuisnetwerk) Number of icons loaded = 3
2021-01-22 15:48:38.326 (Thuisnetwerk) onStart: Items = UnifiPresenceAnyone
2021-01-22 15:48:38.326 (Thuisnetwerk) onStart: Icon 102 Name = UnifiPresence
2021-01-22 15:48:38.326 (Thuisnetwerk) onStart: Items = UnifiPresenceOverride
2021-01-22 15:48:38.326 (Thuisnetwerk) onStart: Icon 103 Name = UnifiPresence
2021-01-22 15:48:38.326 (Thuisnetwerk) onStart: Items = UnifiPresenceDevice
2021-01-22 15:48:38.326 (Thuisnetwerk) onStart: Icon 104 Name = UnifiPresence
2021-01-22 15:48:38.326 (Thuisnetwerk) login: called
2021-01-22 15:48:38.322 Status: (Thuisnetwerk) Entering work loop.
2021-01-22 15:48:38.323 Status: (Thuisnetwerk) Initialized version 2.7.8, author 'Wizzard72'
2021-01-22 15:48:39.503 (Thuisnetwerk) login: Login successful into Unifi Controller
2021-01-22 15:48:39.534 (Thuisnetwerk) detect Unifi Devices: Invalid login, or login has expired
2021-01-22 15:48:39.534 (Thuisnetwerk) create_devices: Found phone to monitor from configuration = David=cc:21:19:03:9b:7f
2021-01-22 15:48:39.534 (Thuisnetwerk) create_devices: Found phone to monitor from configuration = Evi=ae:ae:6f:90:58:24
2021-01-22 15:48:39.535 (Thuisnetwerk) onStart: Phone Naam = OverRide | 00:00:00:00:00:00 | 255 | Off | No | No
2021-01-22 15:48:39.535 (Thuisnetwerk) onStart: Phone Naam = David | cc:21:19:03:9b:7f | 50 | Off | No | No
2021-01-22 15:48:39.535 (Thuisnetwerk) onStart: Phone Naam = Evi | ae:ae:6f:90:58:24 | 51 | Off | No | No
2021-01-22 15:48:39.535 (Thuisnetwerk) Pushing 'PollIntervalDirective' on to queue
2021-01-22 15:48:39.535 (Thuisnetwerk) Processing 'PollIntervalDirective' message
2021-01-22 15:48:39.535 (Thuisnetwerk) Heartbeat interval set to: 5.
2021-01-22 15:48:49.037 (Thuisnetwerk) Pushing 'onHeartbeatCallback' on to queue
2021-01-22 15:48:49.055 (Thuisnetwerk) Processing 'onHeartbeatCallback' message
2021-01-22 15:48:49.055 (Thuisnetwerk) Calling message handler 'onHeartbeat'.
2021-01-22 15:48:49.055 (Thuisnetwerk) onHeartbeat: called
2021-01-22 15:48:49.055 (Thuisnetwerk) onHeartbeat: Attempting to reconnect Unifi Controller
2021-01-22 15:48:49.055 (Thuisnetwerk) login: called
2021-01-22 15:48:49.824 (Thuisnetwerk) login: Login successful into Unifi Controller
2021-01-22 15:48:49.825 (Thuisnetwerk) onHeartbeat: Requesting Unifi Controller details
2021-01-22 15:48:49.848 (Thuisnetwerk) request_details: Invalid login, or login has expired
2021-01-22 15:48:49.848 (Thuisnetwerk) login: called
2021-01-22 15:48:50.544 (Thuisnetwerk) login: Login successful into Unifi Controller
2021-01-22 15:48:50.568 (Thuisnetwerk) request_online_phones: Invalid login, or login has expired
2021-01-22 15:48:50.568 (Thuisnetwerk) login: called
wizzard72
Posts: 116
Joined: Friday 20 December 2013 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by wizzard72 »

@David82 can you enabled the setting 'Enable Geofencing devices' to see if it then works
wizzard72
Posts: 116
Joined: Friday 20 December 2013 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by wizzard72 »

CronoS wrote: Wednesday 20 January 2021 20:39 I have got a question regarding the plugin. I have not used it yet, but I have used the old DZvent script for quite some time now.

My question is, I detect multiple devices using the script, this beside the phones. An example is to detect if my PC is still one after some time to get a notifcation, the same for the TV's which I use in other scripts. The reason is that I use the DZvent with Unifi, is that I do not want to ping around the whole day to multiple devices every minute. I like using the script, because when it is executed everything is detected in the same timeframe.

Now I see in the Plugin that there is a button Unifi Anyone, this is indeed the case with phones.. but I do not want to use it for other devices. Is that changable? So Is it still, for my environment, a good idea to switch over to the plugin?
You can use the plugin for detecting your pc if it's on the wireless network. When the pc is on also the device AnyOne is turned on and visa versa. You can't delete the AnyOne device, or the other automatically generated devices, otherwise the plugin generates errors. If you're fine with that, you can use the plugin for your use case.
David82
Posts: 4
Joined: Monday 21 May 2018 22:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by David82 »

wizzard72 wrote: Tuesday 02 February 2021 20:13 @David82 can you enabled the setting 'Enable Geofencing devices' to see if it then works
I changed the name of te network to default and it works


for the temperature remains: 0
Unifi Switch Flex Mini (USMINI)
UniFi Security Gateway 3P (UGW3)
UniFi AP-AC-Lite (U7LT)
UniFi Switch 8 POE-60W (US8P60)
Unifi Switch Flex Mini (USMINI)

for the UniFi Switch 8 POE-60W (US8P60) the cpu and memory remains 0
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by CronoS »

wizzard72 wrote: Tuesday 02 February 2021 20:26
You can use the plugin for detecting your pc if it's on the wireless network. When the pc is on also the device AnyOne is turned on and visa versa. You can't delete the AnyOne device, or the other automatically generated devices, otherwise the plugin generates errors. If you're fine with that, you can use the plugin for your use case.
Thanks. I will consider it, the AnyOne button is not suitable for me in this circumstance. But all my switches are also unifi, so all my LAN connected devices are also known in the Unifi controller and therefore the Mac address of wired devices can be read from the controller. Is the plugin not reading devices from switches? Ony wireless?
I can also create a dzvent script myself ofcourse with the state of the phones to trigger a dummy AnyOne switch, I am already using something like that.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by besix »

Hello
The plug works great, but only to restart the Raspberry.
There are some bugs after restart.

Code: Select all

2021-02-03 21:59:00.386 (Obecność) Debug logging mask set to: NONE
2021-02-03 21:59:00.386 (Obecność) setVersionCheck - Plugin allowed to start (triggered by: onStart)
2021-02-03 21:59:00.386 (Obecność) Number of icons loaded = 3
2021-02-03 21:59:00.386 (Obecność) onStart: Items = UnifiPresenceAnyone
2021-02-03 21:59:00.386 (Obecność) onStart: Icon 101 Name = UnifiPresence
2021-02-03 21:59:00.386 (Obecność) onStart: Items = UnifiPresenceOverride
2021-02-03 21:59:00.386 (Obecność) onStart: Icon 102 Name = UnifiPresence
2021-02-03 21:59:00.386 (Obecność) onStart: Items = UnifiPresenceDevice
2021-02-03 21:59:00.386 (Obecność) onStart: Icon 103 Name = UnifiPresence
2021-02-03 21:59:10.127 (Obecność) onHeartbeat: Attempting to reconnect Unifi Controller
2021-02-03 21:59:10.134 Error: (Obecność) 'onHeartbeat' failed 'ConnectionError'.
2021-02-03 21:59:10.134 Error: (Obecność) ----> Line 1237 in '/home/pi/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onHeartbeat
2021-02-03 21:59:10.135 Error: (Obecność) ----> Line 413 in '/home/pi/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onHeartbeat
2021-02-03 21:59:10.135 Error: (Obecność) ----> Line 451 in '/home/pi/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function login
2021-02-03 21:59:10.135 Error: (Obecność) ----> Line 581 in '/usr/lib/python3/dist-packages/requests/sessions.py', function post
2021-02-03 21:59:10.135 Error: (Obecność) ----> Line 533 in '/usr/lib/python3/dist-packages/requests/sessions.py', function request
2021-02-03 21:59:10.135 Error: (Obecność) ----> Line 646 in '/usr/lib/python3/dist-packages/requests/sessions.py', function send
2021-02-03 21:59:10.135 Error: (Obecność) ----> Line 516 in '/usr/lib/python3/dist-packages/requests/adapters.py', function send
If I go to hardware and do a plugin update, everything works again Ok

Code: Select all

2021-02-03 22:01:14.585 (Obecność) UpdateDevice: Update 7:'7.1' (Obecność - 11:e8:11:fd:11:7b CPU)
2021-02-03 22:01:14.590 (Obecność) UpdateDevice: Update 34:'34.6' (Obecność - 11:e8:11:fd:11:7b Memory)
2021-02-03 22:01:14.641 (Obecność) ProcessDevices: Phone 'Grze' connected to the Unifi Controller
2021-02-03 22:01:14.641 (Obecność) ProcessDevices: Phone 'Jo' connected to the Unifi Controller
2021-02-03 22:01:14.641 (Obecność) ProcessDevices: Total Phones connected = 2
2021-02-03 22:01:24.546 (Obecność) UpdateDevice: Update 34:'34.4' (Obecność - 11:e8:11:fd:11:7b Memory)
2021-02-03 22:01:34.624 (Obecność) UpdateDevice: Update 13:'13.7' (Obecność - 11:e8:11:fd:11:7b CPU)
2021-02-03 22:01:34.628 (Obecność) UpdateDevice: Update 34:'34.2' (Obecność - 11:e8:11:fd:11:7b Memory)
2021-02-03 22:01:49.613 (Obecność) UpdateDevice: Update 34:'34.1' (Obecność - 11:e8:11:fd:11:7b Memory)
2021-02-03 22:01:59.617 (Obecność) UpdateDevice: Update 34:'34.4' (Obecność - 11:e8:11:fd:11:7b Memory)
2021-02-03 22:02:14.643 (Obecność) UpdateDevice: Update 34:'34.5' (Obecność - 11:e8:11:fd:11:7b Memory)
wizzard72
Posts: 116
Joined: Friday 20 December 2013 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by wizzard72 »

@besix, is the Unifi Controller installed on the same system as Domoticz? It takes a while for Unifi Controller to be started up. In the meantime you get these errors. If it is started up the plugin login automaticly.
wizzard72
Posts: 116
Joined: Friday 20 December 2013 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by wizzard72 »

David82 wrote: Tuesday 02 February 2021 23:33
wizzard72 wrote: Tuesday 02 February 2021 20:13 @David82 can you enabled the setting 'Enable Geofencing devices' to see if it then works
I changed the name of te network to default and it works


for the temperature remains: 0
Unifi Switch Flex Mini (USMINI)
UniFi Security Gateway 3P (UGW3)
UniFi AP-AC-Lite (U7LT)
UniFi Switch 8 POE-60W (US8P60)
Unifi Switch Flex Mini (USMINI)

for the UniFi Switch 8 POE-60W (US8P60) the cpu and memory remains 0
I'm not sure the US8P60 has these sensors. Can you send me the output of:
http://UnifiControllerIP:Port/api/s/default/stat/device
kamko007
Posts: 1
Joined: Saturday 20 February 2021 23:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by kamko007 »

I have errors in protocol too. I'm running unifi controller on same hw as Domoticz, first detection of devices ok, but no updates, no statuses.
And second problem - after updating plugin parameters, phones are created again, so i have duplicate phone switches.

2021-02-20 23:20:51.451 Error: (Unifi-Z-10) 'onHeartbeat' failed 'IndexError':'string index out of range'.
2021-02-20 23:20:51.451 Error: (Unifi-Z-10) ----> Line 1237 in '/usr/local/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onHeartbeat
2021-02-20 23:20:51.451 Error: (Unifi-Z-10) ----> Line 416 in '/usr/local/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onHeartbeat
wizzard72
Posts: 116
Joined: Friday 20 December 2013 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Ubiquiti Unifi Presence

Post by wizzard72 »

kamko007 wrote: Saturday 20 February 2021 23:28 I have errors in protocol too. I'm running unifi controller on same hw as Domoticz, first detection of devices ok, but no updates, no statuses.
And second problem - after updating plugin parameters, phones are created again, so i have duplicate phone switches.

2021-02-20 23:20:51.451 Error: (Unifi-Z-10) 'onHeartbeat' failed 'IndexError':'string index out of range'.
2021-02-20 23:20:51.451 Error: (Unifi-Z-10) ----> Line 1237 in '/usr/local/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onHeartbeat
2021-02-20 23:20:51.451 Error: (Unifi-Z-10) ----> Line 416 in '/usr/local/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onHeartbeat
Remove the " -" in the plugin name. Haven't fixed it yet. I created a issue on Github for it.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest