That is pretty simple:
Create an item that subscribes to the data that are sent to the MQTT Broker by your ESP.
In my case, I do have an ESP that is using the pubsubclient to publish the following data:
So once the ESP boots up and connects to the WiFi it sends “-1”.
This currently is for testing purposes since i am waiting for the rest of the hardware. But you should get the idea.
If Sascha’s reply did not help, check out my thread here as it gives you rules and items to send and receive MQTT messages. The first post in the thread is long but it should spark some ideas and you have the knowledge that they are working examples you can copy and adjust to what you need…
oke,
i installed MQTT.fx - here i have a reading on the esp through the broker on the same computer as openhab. So the MQTT broker works and the esp get’s its data to the broker
i added this to .item
Number Temperature_dht "Temperatuur DHT22 [%.1f °C]" <temperature> {mqtt="<[localbroker:dht22_01/temp/Temperature:state:default]"}
If your broker is running in the same machine then you can use tcp://127.0.0.1:1883
the clientId doesn’t really matter as long as it is unique to the broker
I have set up mosquitto for username and password
If you haven’t you don’t need the last two lines and can be commented out with ‘#’
Hi,
I just re-read the topic and it looks like the openhab is connecting to mosquitto
Sorry.
your broker name is localbroker (no capitals) so your first item definition is correct
What topic does your ESP publishes the value under
The topic in openHAB must be exactly the same.