Convert nut to a multi step config flow (#33803)
* Convert nut to a multi step config flow * Users can now choose the ups they want in step 2 (or skipped if only one) * Users can now select the resources they want to monitor based on what is actually available on the device * CONF_NAME has been removed as we now get the name from NUT * Device classes have been added which allows the battery charge state to be seen in the devices UI * Remove update_interval as its for a followup PR * explict * reduce * fix bug, add tests for options flow * Test for dupe import * Test for dupe import * Call step directly * Update homeassistant/components/nut/config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
1 parent
db9b6aba31
commit
7383e81609
7 files changed
+482
-160
No files matched your search
@@ -23,6 +23,7 @@ from .const import (
|
||||
PYNUT_FIRMWARE,
|
||||
PYNUT_MANUFACTURER,
|
||||
PYNUT_MODEL,
|
||||
PYNUT_NAME,
|
||||
PYNUT_STATUS,
|
||||
PYNUT_UNIQUE_ID,
|
||||
)
|
||||
@@ -65,6 +66,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
PYNUT_MANUFACTURER: _manufacturer_from_status(status),
|
||||
PYNUT_MODEL: _model_from_status(status),
|
||||
PYNUT_FIRMWARE: _firmware_from_status(status),
|
||||
PYNUT_NAME: data.name,
|
||||
}
|
||||
|
||||
entry.add_update_listener(_async_update_listener)
|
||||
@@ -186,10 +188,19 @@ class PyNUTData:
|
||||
self.update()
|
||||
return self._status
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the ups."""
|
||||
return self._alias
|
||||
|
||||
def list_ups(self):
|
||||
"""List UPSes connected to the NUT server."""
|
||||
return self._client.list_ups()
|
||||
|
||||
def _get_alias(self):
|
||||
"""Get the ups alias from NUT."""
|
||||
try:
|
||||
return next(iter(self._client.list_ups()))
|
||||
return next(iter(self.list_ups()))
|
||||
except PyNUTError as err:
|
||||
_LOGGER.error("Failure getting NUT ups alias, %s", err)
|
||||
return None
|
||||
|
||||
Reference in new issue
Block a user