Hi Everyone
I have recently installed openHABian on my Pi 3 and have the demo house all up and running. I have also got it nicely connected to my.openhab and im able to modify the sitemap and item files and have been using Paper UI to add bindings (my.openHAB and the exec binding).
I have attached a DHT11 module to GPIO pin 4 on the Pi and I have successfully read back the temperature & humidity via a python script.
I am now tripping over being able to implement this sensor inside openHAB2 and get it to appear in the UI correctly. I cannot figure out how to use the exec binding (if indeed this is this is the best method?) and furthermore I have tried to use the logging (Karaf Console) also with little success after reading loads on forums. There is very little on how to use the exec binding on the forums and what is available gets confusing if its for OH1 or OH2 there appears to be a difference!
I have been trying to follow this thread
And my attempt at an exec binding is as follows, created a python script:
#!/usr/bin/python
import sys
import Adafruit_DHT
humidity, temperature = Adafruit_DHT.read_retry(11, 4)
print '{0:0.1f}'.format(temperature)
#print 'Temp: {0:0.1f} C Humidity: {1:0.1f} %'.format(temperature, humidity)
And on the Pi console I get this (if I run as sudo):
[17:23:39] pi@openHABianPi:/etc/openhab2/scripts$ sudo ./DHT11-read-temp-humd.py
[sudo] password for pi:*******
2.0
I thought the sudo might be affecting things so I created a simpler script to just return a number:
#!/usr/bin/python
print '10'
[17:23:54] pi@openHABianPi:/etc/openhab2/scripts$ ./DHT11-read-temp-humd_test.py
10
Permissions are all 777 for both. I have then added this line to my demo.items:
Number Temperature_FF_Workshop "Temperature [%.1f °C]" <temperature> (Temperature, FF_Workshop) {exec="<[/usr/bin/python /etc/openhab2/scripts/DHT11-read-temp-humd_test.py:10000:REGEX((.*?))]"}
And I get this is the UI (and this is the same as I got with the DHT11 read python script so it looks like 20 is some default value!)
So following the thread I have tried to implement this in rules so I can see logging info but unfortunately im very confused by the Karaf logging in OH2. I added this line to my demo.rules:
val tempres executeCommandLine("/etc/openhab2/scripts/DHT11-read-temp-humd_test.py", 5000) logInfo("TestTempRes", tempres)
And I have the following log set
openhab> log:get all
Logger | Level
-------------------------------------------------------------------
ROOT | ERROR
javax.jmdns | ERROR
org.eclipse.smarthome | DEBUG
org.jupnp | ERROR
org.openhab | INFO
org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper | ERROR
smarthome.event | DEBUG
smarthome.event.InboxUpdatedEvent | ERROR
smarthome.event.ItemStateEvent | ERROR
smarthome.event.ThingStatusInfoEvent | ERROR
But I see nothing in the log:tail at all.
I have double checked the exec binding is installed :
Any help would be much appreciated.
Thanks In advance