Hi there,
I have a Sonoff SNZB-02 connected to Sonoff Zigbee Bridge ZBBridge flashed with latest Tasmota firmware.
I managed to connect the bridge to Home Assistant via MQTT broker. I can read values from the temperature/humidity sensor.
The problem is, that the MQTT message is sometimes missing Temperature or Humidity value.
e.q.
{
"ZbReceived": {
"tasmotatest": {
"Device": "0x1F94",
"Name": "tasmotatest",
"Temperature": 23.78,
"Endpoint": 1,
"LinkQuality": 100
}
}
}
MQTT message without Temperature:
{
"ZbReceived": {
"tasmotatest": {
"Device": "0x1F94",
"Name": "tasmotatest",
"BatteryPercentage": 59.5,
"Endpoint": 1,
"LinkQuality": 100
}
}
}
So when I get Temperature value to HA and later the device sends message just with the battery percentage (without Temperature) - the temperature value in HA is set to 0. How can I tell HA, that if the Temperature value is not present in the MQTT message, then the HA would not update the sensor?
Here is my HA configuration:
- platform: mqtt
name: "Tasmota Temperature"
state_topic: "aaa/tasmota1/SENSOR"
value_template: "{{ value_json.ZbReceived.tasmotatest.Temperature }}"
unit_of_measurement: "°C"
availability_topic: "aaa/tasmota1/LWT"
payload_available: "Online"
payload_not_available: "Offline"
device_class: temperature
Thank you for help/guidance.
VDRainer
(🍻)
January 3, 2021, 8:54am
2
This should work for you.
Just give the sensor it’s own value.
- platform: mqtt
state_topic: "home/rtl_433"
name: "Aussen Temp Nexus"
unit_of_measurement: "°C"
value_template: >
{% if value_json is defined and value_json.id == 137 %}
{{ value_json.temperature_C }}
{% else %}
{{ states('sensor.aussen_temp_nexus') }}
{% endif %}
Thank you, very much appreciated
Max
Hi! Could you show how your configuration was with the VDRainer solution? I was unable to configure it here on my HA.
1 Like
frberry
(berry)
May 21, 2023, 6:56pm
5
Hello,
I’m spending my weekend on a fucking bug and I couldn’t find it… so I post my nightmare:
I would like to recover the humidity via a tasmota (MQTT,…).
1- I put a Zigbee sensor that sends humidity to Tasmota (it works!).
2 - Tasmota posts the temperature of the device (0XAE6D) on my MQTT broker. I can see it in the console and via MQTT.fx: (it works!)
3 - Then on Home Assistant, I write in my config.yaml:
and in my entity, the value is not:
Any ideas are very very welcomed!!!
François
frberry
(berry)
May 22, 2023, 6:26pm
6
I solved it… alone!
Here is the functionnal code:
mqtt:
sensor:
- name: "Humidité Cave"
unique_id: "Cellar_hum"
state_topic: "tele/Cave/SENSOR"
value_template: >-
{% if value_json['ZbReceived']['0xAE6D']['Humidity'] > 0 %}
{{ value_json['ZbReceived']['0xAE6D']['Humidity'] }}
{% else %}
{{ states(entity_id) }}
{% endif %}
availability_topic: "tele/Cave/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 0
device_class: "humidity"
expire_after: 86400
unit_of_measurement: '%'
- name: "Température Cave"
unique_id: "Cellar_tem"
state_topic: "tele/Cave/SENSOR"
value_template: >-
{% if value_json['ZbReceived']['0xAE6D']['Temperature'] > 0 %}
{{ value_json['ZbReceived']['0xAE6D']['Temperature'] }}
{% else %}
{{ states(entity_id) }}
{% endif %}
availability_topic: "tele/Cave/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 0
device_class: "Temperature"
expire_after: 86400
unit_of_measurement: '°C'
Please note that values are displayed ONLY if there are new values… No buffering!!!
Then if you want to test it, the best way is to publish a faked post on your MQTT broker with MQTT.fx: