Hey Guys,
i’m using OpenMQTTGateway to read the temperature and humidity from Xiaomi Mijia hygrothermometer and reading it in homeassistant as mqtt sensor.
Configuration:
- platform: mqtt
name: "Temperatur Baby"
state_topic: "home/OMG_Baby/BTtoMQTT/582D3431C7BF"
unit_of_measurement: '°C'
value_template: "{{ value_json.tem }}"
- platform: mqtt
name: "Luftfeuchtigkeit Baby"
state_topic: "home/OMG_Baby/BTtoMQTT/582D3431C7BF"
unit_of_measurement: '%'
value_template: "{{ value_json.hum }}"
It works almost fine. The problem is, that sometimes the gateway sends both, the temp and humidity in one publish and sometimes only one of both values, which leads to an empty value of the “not sent” item.
Examples:
home/OMG_Baby/BTtoMQTT/582D3431C7BF {“hum”:53.5}
or
home/OMG_Baby/BTtoMQTT/582D3431C7BF {“hum”:53.5,“tem”:24.5}
or
home/OMG_Baby/BTtoMQTT/582D3431C7BF {“tem”:24.5}
Is there a way to check if “none” was sent in the last message and keep the last sent value?
Thanks in advance!