inverted_binary_sensor.yaml 971 B

123456789101112131415161718192021222324252627
  1. blueprint:
  2. name: Invert a binary sensor
  3. description: Creates a binary_sensor which holds the inverted value of a reference binary_sensor
  4. domain: template
  5. source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/template/blueprints/inverted_binary_sensor.yaml
  6. input:
  7. reference_entity:
  8. name: Binary sensor to be inverted
  9. description: The binary_sensor which needs to have its value inverted
  10. selector:
  11. entity:
  12. domain: binary_sensor
  13. variables:
  14. reference_entity: !input reference_entity
  15. binary_sensor:
  16. state: >
  17. {% if states(reference_entity) == 'on' %}
  18. off
  19. {% elif states(reference_entity) == 'off' %}
  20. on
  21. {% else %}
  22. {{ states(reference_entity) }}
  23. {% endif %}
  24. # delay_on: not_used in this example
  25. # delay_off: not_used in this example
  26. # auto_off: not_used in this example
  27. availability: "{{ states(reference_entity) not in ('unknown', 'unavailable') }}"