#Sunrise < - > 23:00
1 messages · Page 1 of 1 (latest)
Unfortunately it doesn't work. In this configuration:
"{{ state_attr('sun.sun', 'elevation') > 1 and now() < today_at('23:00') }}"
From the east it was "true", but after sunset it jumped to "false" and I would like it to work until 23:00
It doesn't work :(. It turned off after sunset.
{{ state_attr('sun.sun', 'elevation') > 1 and now().hour < 23 }}
If I have the following, it turns on after 24:00
{{ state_attr('sun.sun', 'elevation') < 1 and now().hour < 23 }}
Thinking back, it probably needs or, not and
If I have "or" then it switches to true just after 00:00
There's really no way to set "true" from sunrise to 11pm?
{{ is_state('sun.sun', 'above_horizon') and now() < today_at("23:00") }}
This outputs true for me now
Unfortunately it doesn't work, the above example starts at sunrise and ends at sunset.
If I give "or" instead of "and" it starts at 00:00 and ends at 23.
I understand that it is impossible to get a "TRUE" response from sunrise to 11pm.
I've done tests and they all fail. Either it jumps "false" after sunset or "true" jumps in just after midnight.
This is only part of the templates I test:
- binary_sensor:
- name: "Po zachodzie słońca -10"
state: "{{ state_attr('sun.sun', 'elevation') < 0 }}" # po zachodzie i działa
- name: "Sensor noc test"
state: "{{ state_attr('sun.sun', 'elevation') < 0 or state_attr('sun.sun', 'elevation') < -10 }}"
- name: "Sensor dzień test"
state: "{{ state_attr('sun.sun', 'elevation') > 0 or state_attr('sun.sun', 'elevation') > -10 }}"
- name: "Sensor dzień test v2"
state: "{{ state_attr('sun.sun', 'elevation') > 0 or state_attr('sun.sun', 'elevation') > -10 or now() < today_at('23:00') }}"
- name: "Od wschodu do 22:59 v1"
state: "{{ is_state('sun.sun', 'above_horizon') < 0 or now() < today_at('23:00') }}"
- name: "Od wschodu do 22:59 v2"
state: "{{ is_state('sun.sun', 'above_horizon') > 0 or now() > today_at('23:00') }}"
- name: "Od wschodu do 22:59 v3"
state: "{{ is_state('sun.sun', 'above_horizon') < 0 or now() > today_at('23:00') }}"
- name: "Od wschodu do 22:59 v4"
state: "{{ is_state('sun.sun', 'above_horizon') > 0 or now() < today_at('23:00') }}"
- name: "Od wschodu do 22:59 v5"
state: "{{ is_state('sun.sun', 'above_horizon') < 0 and now() < today_at('23:00') }}"
- name: "Od wschodu do 22:59 v6"
state: "{{ is_state('sun.sun', 'above_horizon') > 0 and now() > today_at('23:00') }}"
- name: "Od wschodu do 22:59 v7"
state: "{{ is_state('sun.sun', 'above_horizon') < 0 and now() > today_at('23:00') }}"
- name: "Od wschodu do 22:59 v8"
state: "{{ is_state('sun.sun', 'above_horizon') > 0 and now() < today_at('23:00') }}"
- name: "Od wschodu do 22:59 v9"
state: "{{ is_state('sun.sun', 'above_horizon') < 0 and now() < today_at('23:00') }}"
I already have this sensor at home but I can't use it to get the condition to get "true" from sunrise to 23:00. 😭
template:
- trigger:
- platform: sun
# This will update every sunrise
event: sunrise
id: sunrise
- platform: time_pattern
# This will update every night
hours: 23
minutes: 0
id: eleven
binary_sensor:
- name: "Sunrise to 11pm"
state: >
{{ trigger.id == 'sunrise' }}