There is some template "binary_sensor"
.
Let it be this simple example:
binary_sensor:
- platform: ping
host: google.com
count: 2
scan_interval: 60
name: net_is_available_google
- platform: ping
host: ya.ru
count: 2
scan_interval: 60
name: net_is_available_yandex
- platform: template
sensors:
net_is_available_internet:
value_template: "{{ is_state('binary_sensor.net_is_available_google','on') or
is_state('binary_sensor.net_is_available_yandex','on') }}"
device_class: connectivity
I see in History that during startup this template sensor becomes OFF.
Here is just a small part of History for some binary_sensor
's:
There were 4 restarts, and on every restart these sensors were OFF.
I tried to change the sensor’s definition:
value_template: "{% set GOOGLE = 'binary_sensor.net_is_available_google' -%}
{%- set YANDEX = 'binary_sensor.net_is_available_yandex' -%}
{%- if states(GOOGLE) in ['unavailable','unknown'] or
states(YANDEX) in ['unavailable','unknown'] -%}
{{ 'unavailable' }}
{%- else -%}
{{ is_state(GOOGLE,'on') or
is_state(YANDEX,'on') }}
{%- endif %}"
I expected to see a grey stripe on the History (for "unavailable"
) instead of red (for "off"
).
But this does not help.
Then I defined an "availability_template"
:
availability_template: "{% set GOOGLE = 'binary_sensor.net_is_available_google' -%}
{%- set YANDEX = 'binary_sensor.net_is_available_yandex' -%}
{{ not states(GOOGLE) in ['unavailable','unknown'] and
not states(YANDEX) in ['unavailable','unknown'] }}"
Does not help too.
What can I do?
Is it possible to solve it?