Hi all
First of all I’m a completly beginner with Raspberry and OpenHab so be patient with me
I want to send temperature and humidity from DHT11 to my OpenHab. I followed this tutorial but the temperature and humidity is not displayed properly in BasicUI.
I think that I have something wrong in my mqtt settings. I have installed Mosquitto through openhabian-config and installed mqtt bindings in PaperUI.
My mqtt.dhtsensor.py looks like this:
MOSQUITTO_HOST = 'openhabianpi'
MOSQUITTO_PORT = 8080
MOSQUITTO_TEMP_MSG = str(sys.argv[1]) # Old channel name in here
MOSQUITTO_HUMI_MSG = str(sys.argv[2]) # Old channel name now passed by argument
print('Mosquitto Temp MSG {0}'.format(MOSQUITTO_TEMP_MSG))
print('Mosquitto Humidity MSG {0}'.format(MOSQUITTO_HUMI_MSG))
I’m not sure if MOSQUITTO_HOST and PORT is correct is I typed there an adress that I use to connect to my OpenHab.
My demo.items looks like this:
Number Cupboard_temp "Riser temperatuur [%.1f °C]" <temperature> (GF_Corridor) {mqtt="<[mosquitto:cupboard/temperature1:state:default]"}
Number Cupboard_humidity "Riser humidity [%.0f %%]" <line> (GF_Corridor) {mqtt="<[mosquitto:cupboard/humidity1:state:default]"}
Can’t say how/if this script is working however your item setup uses the MQTT syntax for the Binding version ! although you seem to have installed the version 2 binding. On version 2 bindings you need to setup Things, which have channels. Items can connect to those channels.
You need to have a broker-thing (which represents the connection from openHAB to your MQTT broker) AND you need the mqtt things (which represent your devices using the MQTT protokoll).
Only for the later you need to create the channels.
All documented in here
Regarding the problem with the script (are you sure the devices are sending messages) I’d use an external MQTT viewer (like MQTTfx) in order to check if/which messages are really being sent.
MQTTfx shows that you know which message to subscribe to in order to get a temperature or humidity. Create channels for both with a StateTopic holding the respective subscription. As you are getting the value directly from this subscription no transformation should be needed.
All the honor goes the the author of this binding!