I used an example from MQTT Sensor - Home Assistant part “TEMPERATURE AND HUMIDITY SENSORS”. But when all 3 sensor-datas will be sent to HASSIO only one attribute will be shown.
You can see all 3 attributes updating but when the next attribute updates, the previous attribute gets cleared and disapears.
- platform: mqtt
#wind gust
state_topic: "home/rtl_433"
name: "Wind Gust"
unit_of_measurement: 'm/s'
value_template: >
{% if value_json is defined and value_json.model == 'WGR800' %}
{{ value_json.gust }}
{% else %}
{{ states('sensor.wind_gust') }}
{% endif %}
- platform: mqtt
state_topic: 'home/rtl_433'
name: 'Wind Direction'
unit_of_measurement: ''
value_template: >-
{% if value_json is defined and value_json.model == 'WGR800' %}
{% set wd = value_json.direction | int %}
{% if wd <= 11 or wd > 348 %}North
{% elif wd >11 and wd <=34 %}North North East
{% elif wd >34 and wd <=56 %}North East
{% elif wd >56 and wd <=79 %}East North East
{% elif wd >79 and wd <=101 %}East
{% elif wd >101 and wd <=124 %}East South East
{% elif wd >124 and wd <=146 %}South East
{% elif wd >146 and wd <=169 %}South South East
{% elif wd >169 and wd <=191 %}South
{% elif wd >191 and wd <=214 %}South South West
{% elif wd >214 and wd <=236 %}South West
{% elif wd >236 and wd <=259 %}West South West
{% elif wd >259 and wd <=281 %}West
{% elif wd >281 and wd <=304 %}West North West
{% elif wd >304 and wd <=326 %}West North West
{% elif wd >326 and wd <=348 %}North North West
{% endif %}
{% else %}
{{ states('sensor.wind_direction') }}
{% endif %}
i did it the same way as you did. But now it gets strange.
If i do an mqtt.reload event all data gets “unknown”. I need to press the update-button on my zigbee-devices so i get new status updates. After that, all values are known.
But this is not the correct behavior. The values should never get “unknown”.