binary_sensor:
  - platform: template
    sensors:
       puerta_tendedero:
         friendly_name: "Puerta Tendedero"
         entity_id:
           - binary_sensor.puerta_tendedero_primario
           - binary_sensor.puerta_tendedero_secundario
         value_template: >-
          {% 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

