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.54k stars 782 forks source link

Reset of MQTT values (multi gateway setup) #359

Closed tunip closed 5 years ago

tunip commented 5 years ago

Describe the bug I use 3 ESP32 gateways with BT only enabled for my 3 Xiaomi Flower & 7 MiJia devices. MQTT values are cleared from time to time for the MiJia's (Flower sensors are not affected).

Custom OMG settings for each gateway: As I need a unique state_topic in Home Assistant, I removed the Gateway_Name from the topic in config_BT.h. The Gateway_Name is still unique on each ESP32 in User_config.h.

To Reproduce Steps to reproduce the behavior:

  1. Publish to 'OMG/BTtoMQTT/xiaomi-mac'
  2. Subscribe on 'OMG/BTtoMQTT/xiaomi-mac'
  3. See screenshot

Expected behavior In my example, the temperature should not be "cleared" from one of the three gateways.

Screenshots val_set val_del

val_big After next scan interval they are back. But sometimes they are gone.

Environment:

1technophile commented 5 years ago

Hello,

Did you identified the mqtt message that is setting the value to undefined ?

tunip commented 5 years ago

Gateway publish: OMG/BTtoMQTT/4C65A8.....8 {"hum":"63.5"} ...temperature is gone

next scan...

OMG/BTtoMQTT/4C65A8.....8 {"hum":"63.5","tem":"23.2"} ...temperature is back

Why home assistant undefines temperature when only humidity is published from the gateway is a good question. Maybe they expect always all values from the json output. If both values are published everything is fine.

Maybe I need to publish every value in a seperate topic (#define jsonPublishing false).

1technophile commented 5 years ago

We need to search on Hass doc to see if there is a way to don't reset the values when the key is not present, or maybe ask the commmunity in hass forum

tunip commented 5 years ago

You are right. I will ask this in the HA community. Many thx