Skip to content

Commit

Permalink
fix: Update arrival with earlier charge complete and arrival times (#575
Browse files Browse the repository at this point in the history
)

closes #565
  • Loading branch information
InTheDaylight14 authored May 6, 2023
1 parent 9424627 commit 92da756
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/tesla_custom/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,10 @@ def native_value(self) -> Optional[datetime]:
+ timedelta(hours=charge_hours)
- (dt.utcnow() - self._last_update_time)
)
if self._value is None or (new_value - self._value).total_seconds() >= 60:
if (
self._value is None
or abs((new_value - self._value).total_seconds()) >= 60
):
self._value = new_value
if self._car.charging_state in ["Charging", "Complete"]:
return self._value
Expand Down Expand Up @@ -686,7 +689,7 @@ def native_value(self) -> Optional[datetime]:
)
if (
self._datetime_value is None
or (new_value - self._datetime_value).total_seconds() >= 60
or abs((new_value - self._datetime_value).total_seconds()) >= 60
):
self._datetime_value = new_value
return self._datetime_value
Expand Down

0 comments on commit 92da756

Please sign in to comment.