Hi there comming from FHEM, I’m trying to rebuild my shutter config, where I used the sunset / sunrise events to trigger the closure and opening. FHEM had a very nice overview where I was able to see when this Automation will be triggered next (of course only if this is predictable). In HomeAssistant I was unlucky to find someting like this. Does anybody know where to find these information?
Yes I know, but this manual installation doesn’t work either, or maybe I’m too stupid for this. Copied the files manual into a new folder called sun2. Then restartet the whole HA. Still nothing can be found via Config → Integrations, nor (waht should make sense) under HACS.
Sun2 is an integration, not an add-on. Add-ons are only supported by HAOS and Supervised installations and are for separate services, such as an MQTT broker.
That said, sun2 should work, and the files should go under your custom components directory. Is there anything in the log on startup? I would recommend installing it via HACS, just because it’s less of a hassle. Just make sure you remove the manually added files if you wish to take this route. You might need to go to HACS and use the “add custom repo” button on that page, and after that install it. Either way, you won’t see this integration under Settings → Integrations. That’s only for the built-in ones. You’ll either see nothing in the UI, or if you use HACS it will be under HACS’s integrations UI.
The built-in sun integration would be best for this use case (depending on how exact you’d like it to be): The sun integration gives you sunset and sunrise attributes for the next event, whereas sun2 gives you the values for the current day (reference: Sunrise time - #8 by 123). Depending on where you live, it might not differ that much (i.e. change that quickly).
EDIT: Fixed my reversal of the sunrise and sunset events for the two integrations.
Setting the shutter closure to sunset. And if so, because sunset is varying over the year, to see what specific time it is for the next closure and the next opening. And because sunset for today and tomorrow are likely almost the same I could live with this minor inaccuracy.
So what is in the config right now and working the shutter closes at sunset and opens at sunrise, but I’m missing a display that tells me on my dashboard, closure will be at 10pm or so… Right now I have to guess
Try this in your template editor (untested from my side):
Shutters will {{ 'close' if is_state('sun.sun', 'above_horizon') else 'open' }} at {{ state_attr('sun.sun', 'next_dawn') if is_state('sun.sun', 'above_horizon') else state_attr('sun.sun', 'next_dusk') }}.
I don’t know what your automation to open or close the shutters look like, but maybe you want to use the elevation attribute instead. This is all for the built-in sun integration, not the sun2 integration, but you should be able to adapt it.
My question now is. When will this action be triggered. I’d like to see an actual timestamp. Because sunset + 3600 only means 1 hour after sunset, but is this 10pm or 9:45pm or 9:30pm ? That would be wonderful. So I’d like to achieve a view where to see when this automation will be triggered. Maybe I am expecting to much but comming from FHEM, I had a direct overview with this information.
I don’t think that’s possible, but you can make a template sensor that does the calculation. Give it the right device class of timestamp and the UI will interpret it correctly.
I’d use sun2 and then you can see the next values if you like and make it a trigger or condition or both. You can create a sun2 sensor for this pretty easily.
binary_sensor:
- platform: sun2
monitored_conditions:
- elevation:
name: Sun Above Horizon
- elevation:
name: Sun Daylight
above: 12
You can specify your own offset elevation in it and it will create a sensor and then you can see what time it will happen today, tomorrow or yesterday in its attributes as well.
I used the wrong words. You can specify an elevation. Typically though an elevation is similar to an offset except expressed in how high the sun is relative to the event. So if you check the elevation at a 3600 second offset and then use that in hte sensor, you get really close. If you really wanted the offset, you could create a template based on the sun2 attributes easily as well. You know when it will happen, you just add your offset.
Another thing to be careful of, the normal ‘sun’ sensor will always display the NEXT dawn. So if you use sun in a template and expect the current DAWN after it has happened, then you’re not getting it. You’re getting tomorrows.
The sun2 will give you what today’s was queried anytime between midnight to midnight instead. So the use case for both of these really need to be considered.