1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.55k stars 784 forks source link

Json Publishing not being picked up by HA sensor #393

Closed stredwizard closed 5 years ago

stredwizard commented 5 years ago

First and foremost this is great so thank you, I've been using it on a nodemcu as just a IR, RF receiver and Sender for over a year, but decided I wanted some extras like PIR and a temperature sensor as well, I had a spare esp8266-12 laying around so I used that instead and its working great as an RF sender / Receiver, temp and PIR except.....

The payload message for HCSR501 IR detection is {"hcsr501":"true"} which does not match the auto discovered sensor in home assistant, if I publish a true or false message on the topic the sensor performs as expected in HA.

I found the line in ZsensorHCSR501 and I found the section about json publishing in User_config.h, but I'm afraid to make changes here as I'm not sure these will work or be a solution.

I'm using the latest OpenMQTTGateway version 0.9 master

cheers

1technophile commented 5 years ago

Do you think we should better publish: {"hcsr501":true} instead of {"hcsr501":"true"}

stredwizard commented 5 years ago

unfortunately I don't know, {"hcsr501":"true"} As sent by the gateway doesn't work for the auto discovered sensor and if I manually publish your example {"hcsr501":true} that doesn't either, I of course may be missing a point somewhere that I don't understand.

cheers

1technophile commented 5 years ago

I have made a correction to mqtt discovery with HA, could you try last dev branch please?

stredwizard commented 5 years ago

I have loaded the dev branch on a nodemcu with HCSR501 sensor attached, everything seems to work correctly now thank you.

I also have an ESP8266-12 which has the HCSR501, DHT11 and the RF Transciever, takes a little more work to flash this one and hopefully will do this tomorrow, the RF transceiver on this one is paired with two recomended GS107 RF door sensors and I had to write a small node-red flow to get these to work with HA, hopefully the new changes in the dev branch will make these work natively in HA.

Cheers