I like to create a binary sensor where the availability is set depending on another entity
- binary_sensor:
- unique_id: "b_700_close_cover_garden"
availability: >-
{% if (is_state('cover.velux_cover_garden', 'open') or is_state('cover.velux_cover_garden', 'closed')) and
((state_attr('cover.velux_cover_garden', 'current_position') | int(100)) > 0) %}
True
{% else %}
False
{% endif %}
icon: mdi:arrow-down-bold-box-outline
state: >
{% if (is_state('cover.velux_cover_garden', 'open') or is_state('cover.velux_cover_garden', 'closed')) and
((state_attr('cover.velux_cover_garden', 'current_position') | int(100)) > 0) %}
True
{% else %}
False
{% endif %}
attributes:
friendly_name: "B-700: Close Cover Garden"
cover_state: >
{{ states('cover.velux_cover_garden') | title }}
- unique_id: "b_701_open_cover_garden"
icon: mdi:arrow-up-bold-box-outline
state: >
{% if (is_state('cover.velux_cover_garden', 'open') or is_state('cover.velux_cover_garden', 'closed')) and
((state_attr('cover.velux_cover_garden', 'current_position') | int(100)) < 100) %}
True
{% else %}
False
{% endif %}
availability: >
{% if (is_state('cover.velux_cover_garden', 'open') or is_state('cover.velux_cover_garden', 'closed')) and
((state_attr('cover.velux_cover_garden', 'current_position') | int(100)) < 100) %}
True
{% else %}
False
{% endif %}
attributes:
friendly_name: "B-701: Open Cover Garden"
cover_state: >
{{ states('cover.velux_cover_garden') | title }}
Now my problem is that the first sensor is created, the second not. The second is only created if I either comment out the “availability” part or use the same as in the first sensor. However the only difference is that either a > 0 or a < 100 is used. The > 0 is working, the < 100 for some reason not. Does anybody know why this does not work?
P.S. I use the same code for the state, and there it works for both sensors.