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

fix: reduce entity creation code #671

Merged
merged 1 commit into from
Jul 25, 2023
Merged

Conversation

bdraco
Copy link
Contributor

@bdraco bdraco commented Jul 21, 2023

followup to #670

I was trying to speed up the setup a bit as well, but the real cause of the slow setup when the car is asleep is zabuldon/teslajsonpy#416

self._car = car
self._unit_system = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT this is dead code

@@ -12,22 +12,14 @@
from .const import ATTRIBUTION, DOMAIN


class TeslaBaseEntity(CoordinatorEntity):
class TeslaBaseEntity(CoordinatorEntity[TeslaDataUpdateCoordinator]):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoordinatorEntity takes a type var for the coordinator

car: TeslaCar,
coordinator: TeslaDataUpdateCoordinator,
) -> None:
"""Initialise the Tesla car device."""
super().__init__(hass, coordinator)
super().__init__(coordinator)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoordinatorEntity sets self.coordinator

"""Initialise the Tesla device."""
super().__init__(coordinator)
self._coordinator: TeslaDataUpdateCoordinator = coordinator
self.hass = hass
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.hass is set by the entity platform when the entity is added to hass

@bdraco bdraco marked this pull request as ready for review July 21, 2023 19:36
@alandtse alandtse merged commit 96fdb46 into alandtse:dev Jul 25, 2023
6 checks passed
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.

2 participants