-
Notifications
You must be signed in to change notification settings - Fork 100
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
Conversation
followup to alandtse#670
self._car = car | ||
self._unit_system = ( |
There was a problem hiding this comment.
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]): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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