Python plugin: Presence detection from wireless router

Python and python framework

Moderator: leecollings

hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hestia »

Thanks for having tried.
I'll give a try to zigbee2mqtt
Thanks!
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

DeKraker wrote: Wednesday 22 March 2023 15:58
Did the new version (using the soap api) work for you?
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

I've istalled the newest domotics and running from docker compose. I'm currently upgrading the system and when I try to install iDetect from th enew plugins directory I get the following message:

fatal: could not create work tree dir 'iDetect': Permission denied

I don't know what is wrong but what I'm doing will become routing soon!
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

hjzwiers wrote: Saturday 29 July 2023 18:14 I've istalled the newest domotics and running from docker compose. I'm currently upgrading the system and when I try to install iDetect from th enew plugins directory I get the following message:

fatal: could not create work tree dir 'iDetect': Permission denied

I don't know what is wrong but what I'm doing will become routing soon!
Could it be that the user (on the docker host) running the container does not have the correct privileges for the plugins directory?
What "new plugins directory" do you mean? Has there been a change I did not notice?

I am also running domticz 2023.2 inside a docker container without any problems. Getting a docker container setup with all the right python modules used by the plugins can be a pain, but I don't think that is the problem here.
Last edited by EscApe on Sunday 30 July 2023 12:56, edited 1 time in total.
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

I ran the file with sudo and it went fine, sorry :-)
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

hjzwiers wrote: Sunday 30 July 2023 11:55 I ran the file with sudo and it went fine, sorry :-)
That’s alright, I know the feeling ;)
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

This is new, I'm getting a lot of line errors from iDetect, and its not working :-(. I just installed my old file
In the logging i keep getting:
2023-08-01 09:24:58.081 Status: iDetect: Skip this hearbeat ... system is still preparing

This is the errror list I get when I do an update in the hardware screen:
2023-08-01 09:02:19.049 Error: iDetect: _plugin.onStart()
2023-08-01 09:02:19.049 Error: iDetect: File "/home/hjz/domoticz/plugins/iDetect/plugin.py", line 212, in onStart
2023-08-01 09:02:19.049 Error: iDetect: from trackers import poll_methods
2023-08-01 09:02:19.049 Error: iDetect: File "/home/hjz/domoticz/plugins/iDetect/trackers/__init__.py", line 6, in <module>
2023-08-01 09:02:19.049 Error: iDetect: from trackers.ssh_tracker import ssh_tracker
2023-08-01 09:02:19.049 Error: iDetect: File "/home/hjz/domoticz/plugins/iDetect/trackers/ssh_tracker.py", line 8, in <module>
2023-08-01 09:02:19.049 Error: iDetect: import paramiko
2023-08-01 09:02:19.049 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/paramiko/__init__.py", line 22, in <module>
2023-08-01 09:02:19.049 Error: iDetect: from paramiko.transport import (
2023-08-01 09:02:19.049 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/paramiko/transport.py", line 33, in <module>
2023-08-01 09:02:19.049 Error: iDetect: from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes
2023-08-01 09:02:19.049 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/cryptography/hazmat/primitives/ciphers/__init__.py", line 11, in <module>
2023-08-01 09:02:19.049 Error: iDetect: from cryptography.hazmat.primitives.ciphers.base import (
2023-08-01 09:02:19.049 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/cryptography/hazmat/primitives/ciphers/base.py", line 10, in <module>
2023-08-01 09:02:19.049 Error: iDetect: from cryptography.exceptions import (
2023-08-01 09:02:19.049 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/cryptography/exceptions.py", line 9, in <module>
2023-08-01 09:02:19.049 Error: iDetect: from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
2023-08-01 09:02:19.049 Error: iDetect: ImportError: PyO3 modules may only be initialized once per interpreter process

I get the same error (iDetect: Skip this hearbeat ... system is still preparing) when i run the test dummy, so I think there is an install error
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

Another one:

2023-08-01 11:01:06.382 Error: iDetect: Stop: Device 'iDetect - Gonul_phone' Reference Count not correct, expected 1 found 2.
2023-08-01 11:01:06.382 Error: iDetect: Stop: Device 'iDetect - HJZ_phone' Reference Count not correct, expected 1 found 2.
2023-08-01 11:01:06.382 Error: iDetect: Stop: Device 'iDetect - Dilara_phone' Reference Count not correct, expected 1 found 2.
2023-08-01 11:01:06.383 Error: iDetect: Stop: Device 'iDetect - Deniz_phone' Reference Count not correct, expected 1 found 2.
2023-08-01 11:01:06.383 Error: iDetect: Stop: Device 'iDetect - Override' Reference Count not correct, expected 1 found 2.
2023-08-01 11:01:06.628 Error: iDetect: Call to function 'onStart' failed, exception details:
2023-08-01 11:01:06.635 Error: iDetect: Traceback (most recent call last):
2023-08-01 11:01:06.636 Error: iDetect: File "/home/hjz/domoticz/plugins/iDetect/plugin.py", line 431, in onStart
2023-08-01 11:01:06.636 Error: iDetect: _plugin.onStart()
2023-08-01 11:01:06.636 Error: iDetect: File "/home/hjz/domoticz/plugins/iDetect/plugin.py", line 212, in onStart
2023-08-01 11:01:06.636 Error: iDetect: from trackers import poll_methods
2023-08-01 11:01:06.636 Error: iDetect: File "/home/hjz/domoticz/plugins/iDetect/trackers/__init__.py", line 6, in <module>
2023-08-01 11:01:06.636 Error: iDetect: from trackers.ssh_tracker import ssh_tracker
2023-08-01 11:01:06.636 Error: iDetect: File "/home/hjz/domoticz/plugins/iDetect/trackers/ssh_tracker.py", line 8, in <module>
2023-08-01 11:01:06.636 Error: iDetect: import paramiko
2023-08-01 11:01:06.636 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/paramiko/__init__.py", line 22, in <module>
2023-08-01 11:01:06.636 Error: iDetect: from paramiko.transport import (
2023-08-01 11:01:06.636 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/paramiko/transport.py", line 33, in <module>
2023-08-01 11:01:06.636 Error: iDetect: from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes
2023-08-01 11:01:06.636 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/cryptography/hazmat/primitives/ciphers/__init__.py", line 11, in <module>
2023-08-01 11:01:06.636 Error: iDetect: from cryptography.hazmat.primitives.ciphers.base import (
2023-08-01 11:01:06.636 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/cryptography/hazmat/primitives/ciphers/base.py", line 10, in <module>
2023-08-01 11:01:06.636 Error: iDetect: from cryptography.exceptions import (
2023-08-01 11:01:06.636 Error: iDetect: File "/usr/local/lib/python3.9/dist-packages/cryptography/exceptions.py", line 9, in <module>
2023-08-01 11:01:06.636 Error: iDetect: from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
2023-08-01 11:01:06.636 Error: iDetect: ImportError: PyO3 modules may only be initialized once per interpreter process
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

It is working, you need to reload the app and cannot use update ......
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

hjzwiers wrote: Tuesday 01 August 2023 14:17 It is working, you need to reload the app and cannot use update ......
Seems to be a problem for other plugins using cryptography as well and there seems to be no solution yet. I will investigate/experiment when I have some time to spare. In the meantime your work-around seems to be the best option (Restart Domoticz entirely when needed).
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

Based on a link provided by pipiche in viewtopic.php?p=304616#p304616 and some other search results I just downgraded cryptography to 40.0.2 and now I can restart the iDetect plugin without problems.

Code: Select all

python3 pip install cryptography==40.0.2 --upgrade
Edit: It seems to be caused by a change in pyo3 and I guess the version of pyo3 used depends on the version of cryptography used. As far as I know the entire domoticz plugin system is a single process, so this will be a problem for any plugin using cryptography (e.g. for ssl communication). Looks like something that can only be fixed by changing pyo3, cryptography or the domoticz plugin framework.
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

I went to the folder iDetect and to root but when I run the code "python3: can't open file '//pip': [Errno 2] No such file or directory"

I ran it under sudo as well
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

Please try

Code: Select all

sudo pip install cryptography==40.0.2 --upgrade
instead.

This is not related to the plugin but to python module installation and the way your system is configured. All I can say is that the python module must become available to the python environment Domoticz is using.
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

That command ran well
Installing collected packages: cryptography
Attempting uninstall: cryptography
Found existing installation: cryptography 41.0.3
Uninstalling cryptography-41.0.3:
Successfully uninstalled cryptography-41.0.3
Successfully installed cryptography-40.0.2

After running I did an restart, same as before "Status: iDetect: Skip this hearbeat ... system is still preparing"

Restarted system
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

hjzwiers wrote: Tuesday 15 August 2023 8:22 That command ran well
Installing collected packages: cryptography
Attempting uninstall: cryptography
Found existing installation: cryptography 41.0.3
Uninstalling cryptography-41.0.3:
Successfully uninstalled cryptography-41.0.3
Successfully installed cryptography-40.0.2

After running I did an restart, same as before "Status: iDetect: Skip this hearbeat ... system is still preparing"

Restarted system
Did you restart the system or only the plugin after the you installed version 40.0.2?
How is it behaving after you restarted the system?
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

I only restarted domoticz, did not try to run it again ...... should I?
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

hjzwiers wrote: Tuesday 15 August 2023 17:22 I only restarted domoticz, did not try to run it again ...... should I?
I don't know of another way to check if it works.
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

I mean I restarted Domoticz, not the whole PC, does that impact the script? If it does I will restart
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by EscApe »

hjzwiers wrote: Tuesday 15 August 2023 17:34 I mean I restarted Domoticz, not the whole PC, does that impact the script? If it does I will restart
If you only restarted the plugin after downgrading the module, then errors would not surprise me. Domoticz does not restart the entire python environment when only a plugin is restarted.

Theoretically it should be enough to restart Domoticz.
Since we have downgraded a python module it couldn't hurt to restart the system also, just to be sure the entire python environment is reloaded.
hjzwiers
Posts: 215
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by hjzwiers »

Status: iDetect: 192.168.2.1 ====> SSH connection established

After a restart of the complete system, works.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest