Unable to use WallBox python script from domoticz

Python and python framework

Moderator: leecollings

Post Reply
mvroosmalen
Posts: 23
Joined: Saturday 03 December 2016 16:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Unable to use WallBox python script from domoticz

Post by mvroosmalen »

Hi,
I'm struggling with the WallBox python library when using from a script called from Domoticz. When I use the python3 script from terminal all works fine. This is what I've tried so far:

* Create an bash to call the script
/usr/bin/python3 /home/pi/domoticz/scripts/python/WallBox.py
or
Python3 /home/pi/domoticz/scripts/python/WallBox.py

* direct call of the script:
/usr/bin/python3 /home/pi/domoticz/scripts/python/WallBox.py
or
Python3 /home/pi/domoticz/scripts/python/WallBox.py

wallbox.py
#!/usr/bin/python3
import sys
try:
from wallbox import Wallbox
except ImportError:
sys.path.append(sys.path[0] + '/..')
from wallbox import Wallbox

import time
etc



The rights of the script set at 755.

In all cases the wallbox is not found????
This is the domoticz error log:
2021-05-09 13:05:03.830 File "/home/pi/domoticz/scripts/python/WallBox.py", line 8, in <module>
2021-05-09 13:05:03.830 from wallbox import Wallbox
2021-05-09 13:05:03.830 ModuleNotFoundError: No module named 'wallbox'
2021-05-09 13:05:03.831 Error: dzVents: Wallbox: Traceback (most recent call last):
2021-05-09 13:05:03.831 File "/home/pi/domoticz/scripts/python/WallBox.py", line 4, in <module>
2021-05-09 13:05:03.831 from wallbox import Wallbox
2021-05-09 13:05:03.831 ModuleNotFoundError: No module named 'wallbox'
2021-05-09 13:05:03.831
2021-05-09 13:05:03.831 During handling of the above exception, another exception occurred:
2021-05-09 13:05:03.831
2021-05-09 13:05:03.831 Traceback (most recent call last):
2021-05-09 13:05:03.831 File "/home/pi/domoticz/scripts/python/WallBox.py", line 8, in <module>
2021-05-09 13:05:03.831 from wallbox import Wallbox
2021-05-09 13:05:03.831 ModuleNotFoundError: No module named 'wallbox'
2021-05-09 13:05:03.831 ::ERROR::
2021-05-09 13:05:03.831

any suggestions???

Mark
User avatar
waltervl
Posts: 5910
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Unable to use WallBox python script from domoticz

Post by waltervl »

Domoticz service often runs on elevated rights (root).
Did you install the python Wallbox library with sudo?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
cleanm
Posts: 1
Joined: Sunday 09 May 2021 14:17
Target OS: Linux
Domoticz version:
Contact:

Re: Unable to use WallBox python script from domoticz

Post by cleanm »

require root permission
mvroosmalen
Posts: 23
Joined: Saturday 03 December 2016 16:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Unable to use WallBox python script from domoticz

Post by mvroosmalen »

Nope...

The solution is:
#!/usr/bin/python3
import sys
try:
from wallbox import Wallbox
except ImportError:
sys.path.append('/home/pi/.local/lib/python3.7/site-packages')
from wallbox import Wallbox

import time

Thanks for the suggestion anyway

Mark
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest