tchi59
(tchi59)
1
hi,
i configured a mqtt sensor that display outside temperature (coming from my neighbour weather station)
sensor:
- platform: mqtt
device_class: temperature
unit_of_measurement: ‘°F’
name: “thermoLaCrosse”
state_topic: “rtl_433/LaCrosse-WS2310/226”
value_template: “{{ value_json.temperature_F }}”
It is working when i receive the first message with “temperature_F”. The temperature is display
{“time”:“2022-06-29 20:06:30”,“model”:“LaCrosse-WS2310”,“id”:226,“temperature_F”:90.5}
{“time”:“2022-06-29 20:06:30”,“model”:“LaCrosse-WS2310”,“id”:226,“humidity”:42}
{“time”:“2022-06-29 20:06:30”,“model”:“LaCrosse-WS2310”,“id”:226,“wind_avg_m_s”:0,“wind_dir_deg”:112.5}
But when i receive the next msg “humidity” or “wind” message, temperature field becomes 0
Do you know why?
Thanks
finity
2
Because the temperature field is not defined?
you need to create a template to filter that out. the easiest way (for me) is to check if the field is defined.
if yes then use the new data. If not use the existing data.
value_template: >
{% if value_json.temperature_F is defined %}
{{ value_json.temperature_F }}”
{% else %}
{{states('sensor.thermolacrosse') |float}}
{% endif %}
tchi59
(tchi59)
3
thanks i will try right now
Is the 2 quotes at the end are required?
{{ value_json.temperature_F }}”
tchi59
(tchi59)
4
i did that and it is working well
- platform: mqtt
device_class: temperature
unit_of_measurement: ‘°F’
name: “thermolacrosse”
state_topic: “rtl_433/LaCrosse-WS2310/226”
force_update: true
value_template: >
{% if value_json.temperature_F is defined %}
{{ value_json.temperature_F }}
{% else %}
{{ sensor.thermolacrosse }}
{% endif %}
thanks a lot !!!
finity
5
no, sorry, typo.
but I see you already figured that out tho. ![:laughing: :laughing:](https://community.home-assistant.io/images/emoji/twitter/laughing.png?v=12)