hi everyone, I am having a lot of troubles with templating using the MQTT commands from my ESP8266 Zigbee2Tasmota device. Spent several hours of googling and fiddling already.
I can get information no problems from the device, I am just having problems displaying it correctly in HA. I have several devices. I will show an example using an Aqara reed switch
Here is my configuration,yaml
sensor:
- platform: mqtt
name: Kitchen Outside Door
state_topic: "zigbee/tele/41FC/SENSOR"
value_template: "{%- if value_json.ZbReceived.kitchenoutsidedoor.Power == 0 -%} Closed {% elif value_json.ZbReceived.kitchenoutsidedoor.Power == 1 %} Open {% endif %}"
Here are 2 sample MQTT topics which work perfectly
21:47:32 MQT: zigbee/tele/41FC/SENSOR = {"ZbReceived":{"kitchenoutsidedoor":{"Device":"0x41FC","Name":"kitchenoutsidedoor","Power":1,"Endpoint":1,"LinkQuality":94}}}
21:47:34 MQT: zigbee/tele/41FC/SENSOR = {"ZbReceived":{"kitchenoutsidedoor":{"Device":"0x41FC","Name":"kitchenoutsidedoor","Power":0,"Endpoint":1,"LinkQuality":94}}}
HA then breaks and shows no value for this sensor (not even the previous value) because occasionally I’ll get this message coming through:
21:47:35 MQT: zigbee/tele/41FC/SENSOR = {"ZbReceived":{"kitchenoutsidedoor":{"Device":"0x41FC","Name":"kitchenoutsidedoor","BatteryVoltage":3.04,"BatteryPercentage":100,"Endpoint":1,"LinkQuality":89}}}
The right value then populates in HA only if the door is opened/closed again.
How can I ignore a message if there is no “Power” or other parameter I am looking for?
Thanks