From 6b5e7474c870e018e7a69f0108cbda23361e2e88 Mon Sep 17 00:00:00 2001 From: dfcarvajal Date: Sun, 17 Jan 2021 12:52:07 +0100 Subject: [PATCH] FIX template change for datetime --- packages/binary_sensor/puerta_tendedero.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/binary_sensor/puerta_tendedero.yaml b/packages/binary_sensor/puerta_tendedero.yaml index a261613..c56d182 100644 --- a/packages/binary_sensor/puerta_tendedero.yaml +++ b/packages/binary_sensor/puerta_tendedero.yaml @@ -7,6 +7,11 @@ binary_sensor: - binary_sensor.puerta_tendedero_primario - binary_sensor.puerta_tendedero_secundario value_template: >- - {{ is_state('binary_sensor.puerta_tendedero_primario','on') or is_state('binary_sensor.puerta_tendedero_secundario','on') }} + {% if as_timestamp(states.binary_sensor.puerta_tendedero_secundario.last_changed) <= + as_timestamp(states.binary_sensor.puerta_tendedero_primario.last_changed) -%} + {{ states('binary_sensor.puerta_tendedero_primario') }} + {%- else -%} + {{ states('binary_sensor.puerta_tendedero_secundario') }} + {%- endif -%} device_class: door