Closed Spartacus68 closed 11 months ago
What version of sun2 are you using?
Hi pnbruckner,
thanks for reply. I got it to work! Was a mistake of mine, sorry!
But may I ask a question? I defined sunrise and senset with a customized elevation, that means that daylight (repective night) is defined between sunrise and sunset (sunset and sunrise). Is there an easy way to define customized daylight and night with sun2? Or how can I create a condition which is true during "night" respective "daylight"?
Glad you got it working!
Is there an easy way to define customized daylight and night with sun2?
Not directly with the sun2 integration. However, it would be very simple to do with a template sensor:
template:
- sensor:
- name: Daylight
unique_id: custom_daylight
device_class: duration
state_class: measurement
unit_of_measurement: hr
state: >
{{
(states('sensor.su_eingang')|as_datetime - states('sensor.sa_eingang')|as_datetime)
.total_seconds()/3600
}}
Or how can I create a condition which is true during "night" respective "daylight"?
Not exactly sure what you mean by "a condition". Do you mean an automation condition?
You could create a binary_sensor
that is on
(i.e., true) during your custom daylight, and another for night. E.g.,
template:
- binary_sensor:
- name: Day
unique_id: custom_day
state: >
{{ states('sensor.sa_eingang')|as_datetime < now() <= states('sensor.su_eingang')|as_datetime }}
- name: Night
unique_id: custom_night
state: "{{ is_state('binary_sensor.day', 'off') }}"
Then you could use those for automation conditions.
Hello pnbrucker,
very cool! with the binary_sensor! It works great. And yes, the question was, how I can use this as an condition for automations. I think I have the solution now! Many, many thanks for your great support.
Spartacus
Hi,
I am trying to trigger on time_at_elevation but it is not working. Is this an issue or isnßt in working yet?
in sun2.yaml: