ad-ha / mg-saic-ha

MG SAIC Custom Integration for Home Assistant
MIT License
14 stars 1 forks source link

[REQ] last (+ next?) updated timestamp sensor #49

Open brettmc opened 2 days ago

brettmc commented 2 days ago

Is your feature request related to a problem?

Please describe the problem

I would like to see how recent my sensor data is, so I can decide whether to trigger a manual refresh. There is a timestamp associated with the update_vehicle_data button, but it seems to be the last time that the button was pressed (and is unrelated to success/fail, and also not updated by the schedule-based refresh)

Describe the solution you'd like

A timestamp-based sensor which shows last successful update from API that I can display. Possibly also useful would be a sensor for the next update, since I see it's calculated differently if the car is charging or not.

Describe alternatives you've considered

I don't think there is another way to get this info, it would not be returned by the API since it's only known by the integration

Additional context

The iSmart app has a last update element which I think is conceptually the same.

ad-ha commented 2 days ago

Hi @brettmc

Thanks for the feedback.

Do you mean something like this: image

You may add this information to any entity while using a tile card: image

Just add "Last updated" on the State content option.

I believe this is the easiest way and that might adapt to your needs.

brettmc commented 2 days ago

Just add "Last updated" on the State content option.

I didn't know I could do that, it's useful! I notice that the last update field doesn't change if the value doesn't, but adding it to something more variable like outside temperature does change more often. As a user, I might not be able to see a difference between "updated but nothing changed" vs "failed to update"

Is there a sensor that always updates after an API refresh, so that I could use it's last update as a proxy for how recent the data is?

ad-ha commented 2 days ago

Is there a sensor that always updates after an API refresh, so that I could use it's last update as a proxy for how recent the data is?

Not really. I can have a look and check if I may craft a sensor to have the last update timespan.