1
mirror of https://github.com/home-assistant/core synced 2024-08-06 09:34:49 +02:00

Apply some suggestions from poolsense code review (#37440)

This commit is contained in:
Chris Talkington 2020-07-03 17:38:05 -05:00 committed by GitHub
parent ccb77ba1e9
commit 1879183b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -47,7 +47,7 @@ class PoolSenseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
if not api_key_valid:
self._errors["base"] = "auth"
self._errors["base"] = "invalid_auth"
if not self._errors:
return self.async_create_entry(

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):

View File

@ -29,7 +29,7 @@ async def test_invalid_credentials(hass):
)
assert result["type"] == "form"
assert result["errors"] == {"base": "auth"}
assert result["errors"] == {"base": "invalid_auth"}
async def test_valid_credentials(hass):