As you can see I change the scene of the lights according to the elevation of the sun. In winter in my city the sun sets around 4.30pm but in summer only after 9pm so I can’t keep the same triggers in winter and summer otherwise the last lights would turn on late at night. The only way I’ve thought of is to manually change the sun elevation conditions every time the season changes … So I’m looking for a way to automate these conditions as well.
I hope I was clearer than before.
Seems like there should be 100 different ways to do with this by simply checking the date (now().month).
One thought is to have 2 (or 3 or 4 or whatever you need) different light automations for the different seasons.
Then have a HA automation turn one automation off and the other one on if date = X
Another thought (if you want to keep it one automation for the lights) would be to have input_boolean variables and allow HA automation to toggle them appropriately based off of the date.
Then put the input_boolean as a condition inside the action like so:
automation:
trigger:
platform: state
entity_id: …
to: ‘on’
action:
- service: …
data:
message: …
- condition: and
conditions:
- condition: template
value_template: ‘…’
- service: switch.turn_on
entity_id: switch…
I thought this too and I think it’s a great way to manage what I’m looking for
Yes, this is also good but I have to understand well how to create automation with input_boolean.
Could you give me an example how to handle the boolean?
If you see my automation, I make the lights turn on when the sun is about to set and not at a fixed time. this is because in winter the sun sets at 16 - 16:30 while in summer at 20: 30-21 so if you only used time as a trigger the lights would always turn on at the same time both in winter and in summer … namely at 16-16: 30
the sun sensor also reports above_horizon and below_horizon (sunset)
why not just trigger on below_horizon then you only need the 1 trigger since the sensor will auto-adjust all year?
The best thing would give during the whole year but I know it is very complicated, so I think the best solution is to create more than one automation and manage everything through a single automation with the season sensor.
If you can give me some examples with the boolean input …
If you try to do this with one automation it will get ridiculously complicated so I would create 4 different automations and use one season as a condition in each automation.
Let’s assume that the automation above has the correct elevations for the summer season. You could then use the following:
THen you will create 3 more automations - one for each of the other seasons.
You will substitute the names of the other seasons in the “id” & “alias” sections. And you will change the first condition to be the proper season state.
Finally you will put in the elevation numbers you want for each of the different seasons.
Because you have only one season as a condition in each automation only those actions will be taken corresponding to that season.
I really think that is the easiest (only?) way to get the behavior you want.
Yes, thanks, it was the first idea I had but I wanted to compare myself with others to see if there was a better solution. Now I will create the other automations and only time will tell if everything works as intended …
seems you shouldn’t trigger on sun elevation at all, but on light_level, which is the absolute value you need and is independent of season, weather conditions or what have you.
maybe Phils Illuminance sensor can help you out, if you don’t have a device measuring light_level for you.
there’s even an virtual light_level sensor (although it is partly based on the elevation) which people seem to find helpful:
# https://community.home-assistant.io/t/virtual-light-sensor/31975/15
virtual_light:
friendly_name: Virtual light
value_template: >
{% set elevation = state_attr('sun.sun','elevation')|float %}
{% set cloud_coverage = states('sensor.openweathermap_coverage')|float %}
{% set cloud_factor = (1 - (0.75 * (cloud_coverage / 100) ** 3)) %}
{% set min_elevation = -6 %}
{% set max_elevation = 90 %}
{% set adjusted_elevation = elevation - min_elevation %}
{% set adjusted_elevation = [adjusted_elevation,0]|max %}
{% set adjusted_elevation = [adjusted_elevation,max_elevation - min_elevation]|min %}
{% set adjusted_elevation = adjusted_elevation / (max_elevation - min_elevation) %}
{% set adjusted_elevation = adjusted_elevation %}
{% set adjusted_elevation = adjusted_elevation * 100 %}
{% set brightness = adjusted_elevation * cloud_factor %}
{{brightness|round}}
unit_of_measurement: '%'
device_class: illuminance
it looked to me like you want to turn on the lights when the sun sets.(because you specifically say that is what you are doing) which “below_horizon” would achieve all year long.
If you look at the full automation posted above he is not just turning on the lights. He’s turning on different lights based on the sun elevation as it gets darker.
I have puzzled with this problem. My objective was to open blinds when the sun had risen enough to no longer shine into the windows.
I worked out that aizimuth and elevation are both needed to cater for seasons. However I haven’t mastered the mathematics to get useful answers.