timer-bar-card
timer-bar-card copied to clipboard
Use Different Values for the idle and active states
First off, great card! Love that it's so versatile already.
Currently I have an automation that fires a notification every 30 minutes that my garage door is open. It's triggered whenever cover.main_door != 'closed'
. I'm not using timers, but a long running automation.
I'm thinking it'd be an additional key (on the entity OR on the whole card):
idle: closed
active: open
I know I could just move these over to timers, I'm just not a fan of the idea of creating timers in the configuration.yaml
Sorry I don't understand; what is the additional key for?
Are trying to create a timer to show how much time is left until the automation fires? You can use active_state
(I think this is what you're looking for?) so the progress bar shows up when the garage is open and the translations
option in case you want to display "Idle" instead of "closed".
I don't have examples of them all together but see the sprinkler example, the Nonstandard Entity Config section, and this one with translations.
Not positive about OP's original question, but in a related vein the ability to pick a different attribute to use for State would be helpful to me.
Use Case: Add Amazon Echo Timer as a timer bar card
Card Config:
type: custom:timer-bar-card
entities:
- sensor.bailey_s_echo_next_timer
bar_direction: rtl
bar_foreground: '#eee'
bar_background: 'var(--mdc-theme-primary, #6200ee)'
start_time:
attribute: process_timestamp
end_time:
attribute: prior_value
bar_width: 35%
filter: false
debug: true
Card Debug Output:
State: 2021-08-10T09:01:04-05:00 ( = idle mode)
Duration: 389.246 second
Time remaining: 338.322
Counter: 338.323
As you can see, the State
attribute for the entity is set to the end_time making it a dynamic value. The way this entity seems to work is that State=None
when idle, and State=<end_time>
when active.
Do the current config options provide a way to handle this?
Would a concept like default state help? And then idle would be State=None
and default would be active.
Yes, I think that makes sense. Correction to my earlier documentation, for this particular entity when there is no Timer active State='unavailable'
.
State: unavailable ( = idle mode)
Duration: NaN second
Time remaining: NaN
Counter: NaN
Alternatively, I have another idea (I really didn't think this through enough the first time). Since you have both a start time and an end time, the card can simply assume the timer is active if start_time <= now() <= end_time
.
Sorry about just now responding, I somehow missed the notification.
To my original comment, what I'm wanting is to be able to have the timer card basically count up to a specific duration, then reset itself it the current state of the garage is still closed
.
The active_state
does kind of do this, but as I revisit this, I just don't see how this can be done without a timer. It might be able to just count up from last changed without the thermometer...
@stephengolub I think you might be needing a timer...
The automation has a last_triggered
attribute, but since it'll only update after your automation has fired it's not a great solution.
Instead of the timer, you might be able to create a template
entity that combines the automation last_triggered
with the garage last_changed
. My templating skills aren't great, but maybe something like this?
template:
- sensor:
- name: "Main door timer"
state: '{{ states("cover.main_door") }}'
attributes:
duration: 00:30:00
start_time: >
{% if as_timestamp(states.cover.main_door.last_changed) > as_timestamp(state_attr('automation.main_door_idk', 'last_triggered')) %}
{{ states.cover.main_door.last_changed.isoformat() }}
{% else %}
{{ state_attr('automation.main_door_idk', 'last_triggered').isoformat() }}
{% endif %}
I haven't tested this much, so hopefully the template doesn't explode with errors. If it does, maybe timer is the way to go.
@philosowaffle check out the guess_mode
option in v1.10
@rianadon guess_mode
seems to be working for me, thanks!