Apply some suggestions from poolsense code review (#37440)
parent
ccb77ba1e9
commit
1879183b24
|
@ -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(
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue