This might be on here somewhere but I haven’t found it yet. What I am trying to do is set a timer or stopwatch that will display on a card that I can put on a dashboard that shows when my washing machine last finished its cycle. I have an automation that currently runs when the cycle finishes and I was trying to tack onto that, but that has not worked. Does anyone do something like this or know of a way to make this work?
Post what you tried and describe what you mean when you say it has not worked. What did you expected to happen that didn’t happen? What did happen that you did not intend?
if you want to know when your cycle finished, and you already have an automation that is triggered when the cycle finishes, then is this what you want:
{{ state_attr(‘automation.triggered_on_cycle_finish’, ‘last_triggered’) }}
There are a lot of things wrong with your example.
The entity ''': automation.wash_cycle_finished
is not valid anywhere, it should be entity: automation.wash_cycle_finished
and nothing more.
Second, calculations done in a single line, again only if the extension supports it, is just as @armedad laid out, two open brackets, the logic, then two closed brackets all enclosed with double quotes, i.e.:
type: "custom:timer-bar-card"
entity: "automation.wash_cycle_finished
- "{{ state_attr('automation.wash_cycle_finished', 'last_triggered') - state_attr('automation.wash_cycle_started, 'last_triggered') }}"
Now that’s still almost certainly not correct but at least the syntax is correct. I don’t know this extension but having an entity defined (entity: automation.wash_cycle_finished
) and then ALSO having a list of calculation seems odd (that dash in front indicates an item of a list). I can see in the docs that it supports entities
(notice the plurality) and then that is a list of hyphenated entities, but not a single entity
followed by a list.
Quickly reading the docs of the extension doesn’t give me any indication of how you can do these types of custom calculations without defining a sensor template as a feeder, but again it could be my ignorance regarding the extension.
You might be better off posting this question in the Git issues of the extension, where other users might be able to guide you on best practices to accomplish your goals.
Most dashboard cards, including Timer Bar Card, do not allow templating.
The Timer Bar Card is for displaying the progress of a timer helper or similar entities from other integrations where you supply at least two of starting time, end time, or duration. That is not what you described in the original post.
In the original post you described displaying “when my washing machine last finished its cycle”. How do you want that displayed? As a datetime string like “2024-02-16 14:59” or as a relative time like “2 hours ago”… or some other way?
Please clarify what you are trying to do and how you want it show on your dashboard.
You seem to have typed random garbage into the configuration.
Probably easiest to create a template sensor in the UI, under Helpers:
State template is:
{{ state_attr('automation.wash_cycle_finished', 'last_triggered') }}
and note the device_class: timestamp
.
Then use that sensor in your timer card.
Was coming here to say the same thing. This use-case would be “show me how much time since it finish” and can easily be done with a template like @armedad posted.
Something like this with the mushroom template card
type: custom:mushroom-template-card
primary: '{{ now() - state_attr(''automation.laundry_automat_dryer'',''last_triggered'') }}'
secondary: ''
icon: mdi:tumble-dryer-off
Or making a template sensor like @Troon posted.
{{ now() - state_attr('automation.laundry_automat_dryer','last_triggered') }}
That can be added using the any card that can display entities:
Yes. Sorry I wasn’t clear but that is exactly what I’m trying to do.
@Troon This is great! Thank you but I’m getting a syntax error. I’ve copied and pasted what you put.
invalid template (TemplateSyntaxError: unexpected char ‘‘’ at 14)
You picked up “pretty” quote marks somewhere… replace all the quote marks with normal ones.
Oh cool…didn’t know you could select that and it would do the “time since” calculation for you. Neat.
This is perfect! Thank you. Next question. Is there a way to change the time format that it displays?
Oops, fixed. I’d copied them from poorly-formatted text above.
Yes. See here:
Thank you all this is terrific!