Getting an error while trying to execute a python script with the exec binding:
2022-10-23 21:48:14.683 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘change_shower_hum-1’ failed: For input string: “Traceback(mostrecentcalllast):
File”/etc/openhab/scripts/hum_shower.py",line4,in
importAdafruit_DHT
ModuleNotFoundError:Nomodulenamed’Adafruit_DHT’
Traceback(mostrecentcalllast):
File"/etc/openhab/scripts/hum_shower.py",line4,in
importAdafruit_DHT
ModuleNotFoundError:Nomodulenamed’Adafruit_DHT’" in change_shower_hum
obviously this is telling me that when executing the python script hum_shower.py that it is not finding the DHT module.
here is my thing:
Thing exec:command:hum_shower [command=“python3 /etc/openhab/scripts/hum_shower.py”, interval=15, autorun=true]
So i can run this command manually in terminal, and it works fine.
Unless, I try to run it as
python /etc/openhab/scripts/hum_shower.py
then I get the same missing module error.
So apparently even though I have stated the script run in python 3 , It still seems to want to run it on the older python (2.7)
Not sure whey this would be happening.
PS> this is a recent upgrade from OH 2 to OH 3. Everything was functioning without issue over on OH 2.
any help or points in what might be happening, would be greatly appreaciated+++
PS> here is the python script:
#!/usr/bin/env python3
import sys
import Adafruit_DHT
sensor = Adafruit_DHT.DHT22
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
temperature = 9/5.0 * temperature + 32
if humidity is not None and temperature is not None:
xyzzy = (‘{0:0.2f}’.format(temperature))
xyzzyy = int(float(xyzzy))
print(xyzzyy)else:
print(‘Failed to get reading. Try again!’)
sys.exit(1)