mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 03:07:50 +00:00

* Add support of Z-Wave.Me Z-Way and RaZberry server (#61182) Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: LawfulChaos <kerbalspacema@gmail.com> * Add switch platform to Z-Wave.Me integration (#64957) Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com> * Add button platform to Z-Wave.Me integration (#65109) Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Fix button controller access (#65117) * Add lock platform to Z-Wave.Me integration #65109 (#65114) Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add sensor platform to Z-Wave.Me integration (#65132) * Sensor Entity * Sensor fixes * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Inline descriotion according to review proposal * State Classes for sensor * Generic sensor * Generic sensor Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add binary sensor platform to Z-Wave.Me integration (#65306) * Binary Sensor Entity * Update docstring Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add Light Entity platform to Z-Wave.Me integration (#65331) * Light Entity * mypy fix * Fixes, ZWaveMePlatforms enum * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Fixes * Fixes * Fixes Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add Thermostat platform to Z-Wave.Me integration #65331 (#65371) * Climate entity * Climate entity * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Climate entity fix * Clean up * cleanup * Import order fix * Correct naming Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Correct zwave_me .coveragerc (#65491) Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: LawfulChaos <kerbalspacema@gmail.com> Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
85 lines
2.6 KiB
Python
85 lines
2.6 KiB
Python
"""Config flow to configure ZWaveMe integration."""
|
|
|
|
import logging
|
|
|
|
from url_normalize import url_normalize
|
|
import voluptuous as vol
|
|
|
|
from homeassistant import config_entries
|
|
from homeassistant.const import CONF_TOKEN, CONF_URL
|
|
|
|
from . import helpers
|
|
from .const import DOMAIN
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
class ZWaveMeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|
"""ZWaveMe integration config flow."""
|
|
|
|
def __init__(self):
|
|
"""Initialize flow."""
|
|
self.url = None
|
|
self.token = None
|
|
self.uuid = None
|
|
|
|
async def async_step_user(self, user_input=None):
|
|
"""Handle a flow initialized by the user or started with zeroconf."""
|
|
errors = {}
|
|
if self.url is None:
|
|
schema = vol.Schema(
|
|
{
|
|
vol.Required(CONF_URL): str,
|
|
vol.Required(CONF_TOKEN): str,
|
|
}
|
|
)
|
|
else:
|
|
schema = vol.Schema(
|
|
{
|
|
vol.Required(CONF_TOKEN): str,
|
|
}
|
|
)
|
|
|
|
if user_input is not None:
|
|
if self.url is None:
|
|
self.url = user_input[CONF_URL]
|
|
|
|
self.token = user_input[CONF_TOKEN]
|
|
if not self.url.startswith(("ws://", "wss://")):
|
|
self.url = f"ws://{self.url}"
|
|
self.url = url_normalize(self.url, default_scheme="ws")
|
|
if self.uuid is None:
|
|
self.uuid = await helpers.get_uuid(self.url, self.token)
|
|
if self.uuid is not None:
|
|
await self.async_set_unique_id(self.uuid, raise_on_progress=False)
|
|
self._abort_if_unique_id_configured()
|
|
else:
|
|
errors["base"] = "no_valid_uuid_set"
|
|
|
|
if not errors:
|
|
return self.async_create_entry(
|
|
title=self.url,
|
|
data={CONF_URL: self.url, CONF_TOKEN: self.token},
|
|
)
|
|
|
|
return self.async_show_form(
|
|
step_id="user",
|
|
data_schema=schema,
|
|
errors=errors,
|
|
)
|
|
|
|
async def async_step_zeroconf(self, discovery_info):
|
|
"""
|
|
Handle a discovered Z-Wave accessory - get url to pass into user step.
|
|
|
|
This flow is triggered by the discovery component.
|
|
"""
|
|
self.url = discovery_info.host
|
|
self.uuid = await helpers.get_uuid(self.url)
|
|
if self.uuid is None:
|
|
return self.async_abort(reason="no_valid_uuid_set")
|
|
|
|
await self.async_set_unique_id(self.uuid)
|
|
self._abort_if_unique_id_configured()
|
|
return await self.async_step_user()
|