I created an automation that is triggered by the sunset. A condition checks if I has been the last 24h not at home. This is done by a binary sensor. But restarting HA changes the state of that binary sensor to false for a short time. Is there any idea how to solve that?
Sry. I have two automations. One for sunrise, one for sunset. The structure is the the same. The condition is the same. The actions are opening and closing covers.
To reduce the complexity of my question I reduced to one case.
input_boolean:
A_home:
name: A is Home
B_home:
name: B is Home
C_home:
name: C is Home
template:
- sensor:
- name: 'A_home'
state: >
{% if is_state('input_boolean.A_home', 'on') %}
Home
{% else %}
not home
{% endif %}
- name: 'B_home'
state: >
{% if is_state('input_boolean.B_home', 'on') %}
Home
{% else %}
not home
{% endif %}
- name: 'C_home'
icon: mdi:account
state: >
{% if is_state('input_boolean.C_home', 'on') %}
Home
{% else %}
not home
{% endif %}
- binary_sensor:
- name: "all at home"
icon: mdi:person
state: >-
{{ is_state('input_boolean.A_home', 'on') and
is_state('input_boolean.B_home', 'on') and
is_state('input_boolean.C_home', 'on') }}
- name: "somebody at home"
icon: mdi:person
state: >-
{{ states('input_boolean.A_home') or
states('input_boolean.B_home') or
states('input_boolean.C_home') }}
- name: "nobody at home"
icon: mdi:person
state: >-
{{ is_state('input_boolean.A_home', 'off') and
is_state('input_boolean.B_home', 'off') and
is_state('input_boolean.C_home', 'off') }}
Whether it is off or unavailable, reloads will probably always say the sensor was not in the same state for 24 hours. So setting a timestamp when the last person leaves is probably a better way to go than for statements that are this long.
It seems like you are using input booleans for what device trackers/person/zone states usually do. Is there a specific reason you are not using that functionality?
Yes. The input boolean is set by homekit. In my case it was the only option which was working properly.
What do you mean with setting a timestamp? How, where to store and how to use?
Can you please give me some more hints?