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

sensor.x_time_to_arrival is timestamp, rather than timedelta #52

Closed
3 tasks done
StephenBrown2 opened this issue Mar 23, 2024 · 2 comments
Closed
3 tasks done

sensor.x_time_to_arrival is timestamp, rather than timedelta #52

StephenBrown2 opened this issue Mar 23, 2024 · 2 comments

Comments

@StephenBrown2
Copy link

Checklist

  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of any previous issues..

Describe the issue

When using the sensor.VEHICLE_time_to_arrival sensor, it is in timestamp format, which I would expect a sensor named _arrival_time to be instead. I would expect _time_to_arrival to instead be a timedelta, so I can easily render it as minutes in notifications and such.

This also affects the _time_to_full_charge sensor.

Expected:

sensor._time_to_arrival: timedelta
sensor._minutes_to_arrival: int
sensor._arrival_time: timestamp
sensor._time_to_full_charge: timedelta
sensor._minutes_to_full_charge: int
sensor._estimated_full_charge_time (can't think of a good name): timestamp

Maybe steal some code from alandtse/tesla for this, since this is what I'm expecting... :-p

TeslaCarArrivalTime: https://github.com/alandtse/tesla/blob/dev/custom_components/tesla_custom/sensor.py#L565-L615

TeslaCarTimeChargeComplete: https://github.com/alandtse/tesla/blob/dev/custom_components/tesla_custom/sensor.py#L474-L509

Reproduction steps

  1. Select sensor.CAR_time_to_arrival in developer tools when vehicle has a destination in the nav
  2. View timestamp, rather than minutes
  3. Notification for "I'll be there in X minutes" requires template for X:
    time_in_minutes: >-
      {{ (as_timestamp(states('sensor.CAR_time_to_arrival')) - now()).total_seconds() // 60 }}
    

Debug logs

No response

@Bre77
Copy link
Contributor

Bre77 commented Mar 23, 2024

So this is a "Home Assistant" thing, the core team do not allow count down sensors. I made a deliberate effort to convert the timedelta into a timestamp to meet these rules. I don't like it, but its a requirement to be in core.

However I take your point about the names not reflecting this accurately. One options is to include the real values in HACS, and renamed (corrected) sensors in core and HACS.

@Bre77
Copy link
Contributor

Bre77 commented Mar 24, 2024

Added in https://github.com/Teslemetry/hass-teslemetry/releases/tag/v1.7.7

Please test it out and close the issue if you think it's working correctly.

@Bre77 Bre77 closed this as completed May 5, 2024
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

No branches or pull requests

2 participants