mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Apply code quality updates to poolsense (#37781)
* Created a binary sensor and corrected some review comments. * Updated the poolsense class and its interface to handle credentials better * Moved the client session to the PoolSense class. * Apply suggestions from code review * Update binary_sensor.py * Update homeassistant/components/poolsense/__init__.py * Update sensor.py * Update binary_sensor.py * Removed unnecessary class variable * Correcting a merge error. Co-authored-by: Chris Talkington <chris@talkingtontech.com>
This commit is contained in:
parent
e9440c49d5
commit
6fe54e31cc
@ -21,11 +21,10 @@ class PoolSenseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize PoolSense config flow."""
|
||||
self._errors = {}
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
"""Handle the initial step."""
|
||||
self._errors = {}
|
||||
errors = {}
|
||||
|
||||
if user_input is not None:
|
||||
await self.async_set_unique_id(user_input[CONF_EMAIL])
|
||||
@ -43,9 +42,9 @@ class PoolSenseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
api_key_valid = await poolsense.test_poolsense_credentials()
|
||||
|
||||
if not api_key_valid:
|
||||
self._errors["base"] = "invalid_auth"
|
||||
errors["base"] = "invalid_auth"
|
||||
|
||||
if not self._errors:
|
||||
if not errors:
|
||||
return self.async_create_entry(
|
||||
title=user_input[CONF_EMAIL],
|
||||
data={
|
||||
@ -59,5 +58,5 @@ class PoolSenseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
data_schema=vol.Schema(
|
||||
{vol.Required(CONF_EMAIL): str, vol.Required(CONF_PASSWORD): str}
|
||||
),
|
||||
errors=self._errors or {},
|
||||
errors=errors or {},
|
||||
)
|
||||
|
@ -1,22 +1,22 @@
|
||||
{
|
||||
"config": {
|
||||
"abort": {
|
||||
"already_configured": "Device is already configured"
|
||||
},
|
||||
"error": {
|
||||
"cannot_connect": "Failed to connect",
|
||||
"invalid_auth": "Invalid authentication",
|
||||
"unknown": "Unexpected error"
|
||||
},
|
||||
"step": {
|
||||
"user": {
|
||||
"title": "PoolSense",
|
||||
"description": "Set up PoolSense integration. Register on the dedicated app to get your username and password. Serial is optional.",
|
||||
"data": {
|
||||
"email": "Email",
|
||||
"password": "Password"
|
||||
},
|
||||
"description": "[%key:common::config_flow::description%]",
|
||||
"title": "PoolSense"
|
||||
}
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"cannot_connect": "Can't connect to PoolSense.",
|
||||
"invalid_auth": "Invalid authorisation details.",
|
||||
"unknown": "Unknown Error."
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "Device already configured."
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user