Détecter ouverture porte de garage

Bonjour,
Moi j’ai fait ceci avec 2 capteurs sonoff et un template. Un seul aimant pour 2 capteurs fixé au chariot.



On peut faire un template de type sensor pour la position « sensor.porte_garage_position »

{% if states('binary_sensor.porte_garage_fermee_contact') == 'off' %}
Fermée
{% elif states('binary_sensor.porte_garage_ouverte_contact') == 'off' %}
Ouverte
{% else %}
Partielle
{% endif %}

Moi du coup, le tout piloté par une carte relais via esphome en pulse en // de mes boutons poussoirs origine pour faire un cover avec position. Le template n’a plus d’intérêt dans ce cas

cover:
  - platform: template
    covers:
      porte_garage:
        device_class: garage
        friendly_name: "Porte garage"
        position_template:
          "{% if is_state('binary_sensor.porte_garage_fermee_contact', 'off') %}
          0
          {% elif is_state('binary_sensor.porte_garage_ouverte_contact', 'off') %}
          100
          {% else %}
          50
          {% endif %}"
        open_cover:
          action: switch.turn_on
          entity_id: switch.pulse_porte_garage
        close_cover:
          action: switch.turn_on
          entity_id: switch.pulse_porte_garage
        stop_cover:
          action: switch.turn_on
          entity_id: switch.pulse_porte_garage
        icon_template: >-
          {% if is_state('binary_sensor.porte_garage_ouverte_contact', 'off') %}
            mdi:garage-open
          {% elif is_state('binary_sensor.porte_garage_fermee_contact', 'off') %}
            mdi:garage
          {% else %}
            mdi:garage-alert
          {% endif %}

1 « J'aime »