-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I start a timer from an attribute? #71
Comments
Taking a look at the debug output, your duration is negative (which means there's no progress bar shown) because the start time is Jan 12 at 14:50 whereas the end time is the same day at 7:24. If you're intending to see a progress bar in the time after sunset but before sunrise (i.e a timer that runs while the sun is down), you'll want the end time to be the next sunrise (which you have), but the start time to be the time the sun set the previous day. There's no such
The first option sounds pretty difficult to me, but for the second you could create a template to calculate the previous sunset, like However, it is also my understanding that the sun entity only has two states: above horizon and below horizon. If you turn off guess mode and provide only an end time, the timer will use the time the sensor last changed its state as the start time, which will be when the sun last either set or rose. So you could also use something like this as your configuration (no template needed): type: custom:timer-bar-card
name: Sun
entities:
- entity: sun.sun
name: Sunrise
icon: mdi:weather-sunset-up
active_state: below_horizon
end_time:
attribute: next_rising
translations:
above_horizon: Not yet ☀️
- entity: sun.sun
name: Sunset
icon: mdi:weather-sunset-down
active_state: above_horizon
end_time:
attribute: next_setting
translations:
below_horizon: Not yet 🌙
text_width: 5em
bar_radius: 4px I really love this example of the card since it shows off a lot of functionality. Thank you so much for the idea. I'll probably put this configuration on the README sometime, which is why I wrote such a long example. I just changed my location before the screenshot, which messed with the sun's last changed date. It stays dark for more than 6 hours here 😄 |
Thank you so much for the help! This is exactly what I wanted. Can't wait to see it in the README so other people can use it 👍 |
Better to keep the issue open as a reminder |
Hi! I'm trying to make a timer start based on when an attribute changes. More specific I want a timer to start when the sun goes down and vise versa. With the current code I can only see if the sun is above or below the horizon. What am I doing wrong?
This is what I have tried with and below is what comes out with it
The text was updated successfully, but these errors were encountered: