Address requested code changes in Tesla (#38680)

* Address requested code changes

* Address ternary operator in sensor
This commit is contained in:
Alan Tse authored and GitHub committed 2020-08-09 09:16:39 -05:00
1 parent ac1f431f91
commit ca3842b150
3 files changed
+16 -30

No files matched your search

+3 -16
View File
@@ -37,22 +37,9 @@ class TeslaSensor(TeslaDevice, Entity):
"""Initialize of the sensor."""
super().__init__(tesla_device, coordinator)
self.type = sensor_type
@property
def name(self) -> str:
"""Return the name of the device."""
return (
self.tesla_device.name
if not self.type
else f"{self.tesla_device.name} ({self.type})"
)
@property
def unique_id(self) -> str:
"""Return a unique ID."""
return (
super().unique_id if not self.type else f"{super().unique_id}_{self.type}"
)
if self.type:
self._name = f"{super().name} ({self.type})"
self._unique_id = f"{super().unique_id}_{self.type}"
@property
def state(self) -> Optional[float]: