@tarikul You should be running OpenHAB MQTT and I would download and install MQTT.fx as that is a helpful tool for debugging MQTT (in Windows) without having to fluff with the command line. I would upgrade your device to R147 as R120 does not contain the retain flag setting which is kind of mandatory for home automation devices (temp/humidity excluded). Who knows, that may even fix your MQTT connection issues? I too am running the native MQTT broker under Hassbian on Pi3 and all of my ESPEasy devices connect to it using OpenHAB MQTT just fine although Iâm running at least version R123.
Thanks for the reply again.
I believe the payload of mqtt message is JSON formatted. Hence, if has to be extracted by some means. In deed, python program is doing the extraction and showing the desired value when we configure the component in YAML. That is what I think anyway. So, if the MQTT payload is not the standard format obviously the default component wouldnât work as expected. However, custom python script can be written to extract the values by regex matching. But, that would be difficult and overkill for the simple task. I believe you are not using the embedded broker. Do you ?
I still think, in my case some broker parameters need to be changed. But without knowing which parameters OpenHAB MQTT are using and mismatching with my broker, I canât progress.
Thanks @xbmcnut I was also thinking this anyway. Yeah I saw in your post you mentioned to use OpenHAB MQTT, thats why I didnât even try to configure HA with Domoticz broker configured on ESP. Usually, I use MQTTBox in Chrome for quick testing. But in this case, I wanted to see the full message details with the topic format and payload. Anyway, I will upgrade the firmware first and report back how it goes. Thanks again for the quick suggestion.
ESPEasy when configured with a temp/humidity device will just publish the value to MQTT broker so the temperature would just come in as say 23. No need to be any harder than that. Iâve just configured ESPEasy yesterday with a DS18b20 temperature sensor and this is publishing to %devicename%/dallas/temperature. That payload data is being picked up by my MagicMirror installation and displaying my office temperature in the bottom left-hand corner shown below. Neat!
Just a thought, have you set the ESP unit number to a unique number between 1 and 32? It canât be zero.
Yeah⌠I mistakenly omitted this step in the beginning and I was not even able to see the data readings.
Hooray! It works now. I just re flashed with R147. No trouble connecting my broker anymore. Now my pir sensor is also working along with the temperature/humidity sensor. I found the data structure is simple esp1/livingroom/temp âpayloadâ which can be readily readable by HA. What a lesson! Thanks guys for your help and suggestion anyway.
That is great. Had a feeling the firmware would resolve your issue. Good luck. Donât forget to tick the MQTT Retain Msg:
setting under Tools > Advanced.
Hi @tarikul
Hooray! It works now. I just re flashed with R147. No trouble connecting my broker anymore. Now my pir sensor is also working along with the temperature/humidity sensor. I found the data structure is simple esp1/livingroom/temp âpayloadâ which can be readily readable by HA. What a lesson! Thanks guys for your help and suggestion anyway.
Good news to listen that worked
Thank for the guide, Iâve followed your project and it all works bar one thing.
When I press the button the relay state changes to 1 but then a few seconds later it changes back to 0.
How can I make it keep the state of 1 until the button is pressed again to make it 0?
I donât know if itâs; A) code, B) wiring C) Type of physical button i used.
setup is exactly like yourâs, running GIT version: v2.0.0-dev8
my wiring (now plugged into D6):
Can you post your HA code for this device? Itâs either a rule issue or MQTT is changing the device state back. A little bit more info about your connection would be helpful.
SUCCESS!!! I had to change the Relay âSwitch Button Typeâ to Active High or Active low, normal is what kept sending it back to 0
- platform: mqtt
name: âlamp buttonâ
state_topic: â/ESP02/relay/stateâ
command_topic: â/ESP02/gpio/13â
payload_on: â1â
payload_off: â0â
qos: 1
retain: true
I did notice in your guide both default states are 0 and my relay is always 1 as below
this is the output when I press the button once:
rest of my setup:
Has anyone got the Sonoff TH10/TH16: Temperature And Humidity Monitoring WiFi Smart Switch working with HA and/or ESPEasy?
It probably works with ESPeasy, but it might be even easier using Sonoff-Tasmota https://github.com/arendst/Sonoff-Tasmota
It seems to support the temperature sensor.