Hi,
While trying to create a python plugin for a beok thermostat using broadlink, the plugin generates an error while domoticz starts up.
this is the error:
[2022-10-15 22:03:47.649 Error: Beokeroni: (Beok) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Beok305F/:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.9/dist-packages'.
2022-10-15 22:03:47.649 Error: Beokeroni: Module Import failed, exception: 'ImportError'
2022-10-15 22:03:47.649 Error: Beokeroni: Module Import failed: ' Name: Domoticz'
2022-10-15 22:03:47.649 Error: Beokeroni: Error Line details not available.
2022-10-15 22:03:47.649 Error: Beokeroni: Exception traceback:
2022-10-15 22:03:47.649 Error: Beokeroni: ----> Line 18 in '/home/pi/domoticz/plugins/Beok305F/plugin.py'
The plugin is in subfolder of \domoticz\plugins\Beok305F
Question now is why it cannot import the Domoticz module . I have searched a lot on this forum and no mention of this issue. Guess my inexperience with Domoticz is cathing up with me.
the plugin also loads the broadlink module and this works fine.
in visual studio code, the Domoticz module also cannot be resolved. what am I missing?
version Domoticz: 2022.1
python version: 3.9.2
below the first part of the script:
'''
<plugin key="Beok" name="Beok Thermostat" author="Onno Meijers" version="1.0.0">
<description>
<h2>Beok Thermostat Interface</h2><br/>
</description>
<params>
<param field="Address" label="IP Address" width="200px" required="true"/>
<param field="Port" label="Port" width="30px" required="true"/>
<param field="Mode1" label="MAC Address" width="200px" required="true">
<description>e.g. XX:XX:XX:...</description>
</param>
<param field="Mode2" label="Type" width="50px" required="true"/>
</params>
</plugin>
'''
import broadlink
import Domoticz
from Domoticz import Devices, Parameters
class BasePlugin:
enabled = False
def __init__(self):
#self.var = 123
return
def onStart(self):
# thermostat ip and mac address
ip = Parameters['Address']
port = int(Parameters['Port'])
mac = ['Mode1']
type = int(Parameters['Mode2']) # Thermostat type
# Convert the mac address to bytes (from hex)
mac_bytes = bytearray.fromhex(self.host_mac.replace(':',''))
# Establish the device
self.thermostat = broadlink.hysen((ip,port), mac_bytes, type)
# Authenticate yourself
self.thermostat.auth()
#x = Domoticz.Log(self.thermostat.get_temp())
#print(x)
plugin.py generates error while importing Domoticz module
Moderator: leecollings
- waltervl
- Posts: 6677
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: plugin.py generates error while importing Domoticz module
I think you have to remove the line:
as this is not needed.
Code: Select all
from Domoticz import Devices, Parameters Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
omeijers
- Posts: 4
- Joined: Monday 12 January 2015 19:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Malden, Netherlands
- Contact:
Re: plugin.py generates error while importing Domoticz module
that does the trick,
thanks
thanks
Who is online
Users browsing this forum: No registered users and 1 guest