Hi,
i have some sensors that uses the same model-name and the same channel the only difference is the subtype provided in my JSON data.
some data:
home/rtl_433/JSON {"time" : "2020-11-01 10:38:19", "model" : "Prologue-TH", "subtype" : 5, "id" : 4, "channel" : 2, "battery_ok" : 1, "temperature_C" : 26.000, "humidity" : 24, "button" : 0}
home/rtl_433/JSON {"time" : "2020-11-01 10:37:33", "model" : "Prologue-TH", "subtype" : 9, "id" : 145, "channel" : 2, "battery_ok" : 0, "temperature_C" : 20.100, "humidity" : 71, "button" : 0}
I tried to configure it as a condition in value_template, but {{paul_temp}} is set to “nothing” if an other sensor publishes its value.
How can i keep the last “correct” value of my sensor?
(the condition itself works)
I tried this in sensors.yaml:
- platform: mqtt
name: "Paul Temp."
icon: "mdi:thermometer"
state_topic: "home/rtl_433/JSON"
unit_of_measurement: "°C"
value_template: >
{% if value_json.model == 'Prologue-TH' and value_json.channel == 2 and value_json.subtype == 5 %}
{% set paul_temp = value_json.temperature_C %}
{{ paul_temp }}
{% else %}
{{ paul_temp }}
{% endif %}
Thank you in advance!