I’m not sure if this already exists and I just haven’t found it. I am working on an automation that uses a service_template to decide to turn things on or off (Christmas Lights)
I would like to also be able to check the time since sunset at the same time as checking whether they are on/off (I realize as it stands it is the same as homeassistant.toggle without ifs)
I did not see a variable in state.sun.sun as it has the next_setting, not the last_setting. But, with conditions you can test sunset with an offset, so I was hoping this is available somewhere…?
I thought of and tried that, it will work, but if I wanted something to also turn the lights on again an hour before sunrise, but only for an hour, then it doesn’t work so well.
What I would really like to know is if I have access to time since or until sunrise or sunset on the current day. Especially if the sunrise or sunset is in the past, as I would like to use this in a service_template (or another template).
Wouldn’t that just be another automation? Why would that make this automation not work? Or maybe this was just a small part of what you’re trying to do and I’m reading too much into it?
Well, I tried to enhance the standard sun component to add these features, but it was rejected. However, I do have a custom version of the sun component that you can use that can have the attributes you’re looking for. Others have used it successfully. You can find information about it here.
If you just have sun:, then it will indeed act just like the standard component. If you want to specify monitored_conditions, and still have it act like the standard component, then you would need:
Of course, there would be no point in doing that. So to that list you would probably want to add other, new attributes, and possibly remove some of the standard, old attributes.