mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Apply some suggestions from poolsense code review (#37440)
This commit is contained in:
parent
ccb77ba1e9
commit
1879183b24
@ -47,7 +47,7 @@ class PoolSenseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not api_key_valid:
|
if not api_key_valid:
|
||||||
self._errors["base"] = "auth"
|
self._errors["base"] = "invalid_auth"
|
||||||
|
|
||||||
if not self._errors:
|
if not self._errors:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
@ -96,12 +96,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
class PoolSenseSensor(Entity):
|
class PoolSenseSensor(Entity):
|
||||||
"""Sensor representing poolsense data."""
|
"""Sensor representing poolsense data."""
|
||||||
|
|
||||||
unique_id = None
|
|
||||||
|
|
||||||
def __init__(self, coordinator, email, info_type):
|
def __init__(self, coordinator, email, info_type):
|
||||||
"""Initialize poolsense sensor."""
|
"""Initialize poolsense sensor."""
|
||||||
self._email = email
|
self._email = email
|
||||||
self.unique_id = f"{email}-{info_type}"
|
self._unique_id = f"{email}-{info_type}"
|
||||||
self.coordinator = coordinator
|
self.coordinator = coordinator
|
||||||
self.info_type = info_type
|
self.info_type = info_type
|
||||||
|
|
||||||
@ -110,10 +108,15 @@ class PoolSenseSensor(Entity):
|
|||||||
"""Return if sensor is available."""
|
"""Return if sensor is available."""
|
||||||
return self.coordinator.last_update_success
|
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
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the particular component."""
|
"""Return the name of the particular component."""
|
||||||
return "PoolSense {}".format(SENSORS[self.info_type]["name"])
|
return f"PoolSense {SENSORS[self.info_type]['name']}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
@ -29,7 +29,7 @@ async def test_invalid_credentials(hass):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["errors"] == {"base": "auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
async def test_valid_credentials(hass):
|
async def test_valid_credentials(hass):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user