Skip to content
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

feat(show_last_updated): initial implementation #1289

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

StaleLoafOfBread
Copy link

Breaking change

I would not consider it a breaking change as it only breaks an undocumented and incorrect behavior. However, for clarity's sake...

In the yaml if you were using show_last_updated instead of show_last_changed, it will now actually show the last updated value instead of the current behavior of showing the last changed value. This behavior in my opinion is a bug but wanted to state it here in case it broke someone's workflow.

Proposed change

Fixes a bug. I can make a bug report if you want. I had not as I thought I'd just make a PR instead.

The bug is that show_last_updated in the yaml is treated as an alias for show_last_changed. This means if someone were to use it, the resulting time stamp would be incorrect since last changed and last updated, although can be the same value, are not always. This also adds the key into the GUI editor.

In this screenshot the first timestamp is last_changed and the second is last_updated. I was unsure which to make show up first so arbitrarily last_updated is shown second.
image

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

type: custom:bubble-card
card_type: button
modules:
  - default
button_type: state
entity: light.living_room
show_last_updated: true
show_attribute: false

Example printscreens/gif

Before it showed last_changed when requesting last_updated
image

After it shows last_updated when requested
image

Can also show both
image

Additional information

I think the above pretty sufficiently describes what this PR does but happy to answer any questions. The motivation behind this PR is that some sensors like waze_travel_time I like to see when it was last updated as opposed to changed so that I know how recently it determined person xyz is 45 min away. If someone stays still for an hour, last_changed will show 1 hour ago but last_updated will show (usually) up to 5 min ago (assuming a 5 min update interval which is the default in this case).

Additional documentation needed.

The documentation was added to the readme.

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests screenshots/gifs have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

  • Documentation added/updated for readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant