Apply some suggestions from poolsense code review (#37440)

This commit is contained in:
Chris Talkington authored and GitHub committed 2020-07-03 15:38:05 -07:00
1 parent ccb77ba1e9
commit 1879183b24
3 files changed
+9 -6

No files matched your search

+7 -4
View File
@@ -96,12 +96,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
class PoolSenseSensor(Entity):
"""Sensor representing poolsense data."""
unique_id = None
def __init__(self, coordinator, email, info_type):
"""Initialize poolsense sensor."""
self._email = email
self.unique_id = f"{email}-{info_type}"
self._unique_id = f"{email}-{info_type}"
self.coordinator = coordinator
self.info_type = info_type
@@ -110,10 +108,15 @@ class PoolSenseSensor(Entity):
"""Return if sensor is available."""
return self.coordinator.last_update_success
@property
def unique_id(self):
"""Return a unique ID to use for this sensor."""
return self._unique_id
@property
def name(self):
"""Return the name of the particular component."""
return "PoolSense {}".format(SENSORS[self.info_type]["name"])
return f"PoolSense {SENSORS[self.info_type]['name']}"
@property
def should_poll(self):