Button that shows when last pressed

I’m new to home assistant and am having trouble getting started. I have what feels like a simple (if a bit offbeat) first project:
I want to get a button that logs the history of when this button is pressed and shows the last time the button was pressed.

I saw the below link but I think the code provided is either incomplete or I’m lost trying to follow it (and the solution was NodeRED, but I’m actively trying to learn HA):

It’s possible that you could simply tie that button to a script and then use the History component to view when the script was activated. You could also make a template sensor that registers activity when the script is run and use the History component to count the number of times in a specified range that the sensor sensed the script running.

Use button-card. :slight_smile: There is already an option built in, that shows the last change (attribute) on a button.

Thanks for the reply @paddy0174 This seems like it should be straightforward but I’m still confused.

I should I could “Add Card” → “Button” → “Show Code View” and add “show_last_changed: true” but I get an error:

Visual editor is not supported for this configuration:

    Key "show_last_changed" is not expected or not supported by the visual editor.

You can still edit your config in YAML.

Does that mean this ‘feature’ is beyond the scope of the GUI & I need to go open the yaml file on the HASS system?

Are you really using the button-card I linked above? Seems like you’re using the button-card from HA. :slight_smile:

The code editor (yaml) is exactly what you need, so you where in the right place. My guess, you’re using the HA button-card. :slight_smile:

1 Like

This is what I get for putting a project to the side >_<

So it looks like “button card” that you linked paddy is no longer being updated? The “check-button-card” linked by Sparky-Dave seems to be in use, so I’m currently using that.

This is what I have so far:

type: custom:button-card
show_last_changed: true
name: test button
label: When this button was last pressed
show_label: true

I see the label & the title, but I don’t see anything about when it was last pressed. Thanks for your patience :slight_smile:

If there’s an alternative I should be using I’d be happy to look into that instead!