Skip to content

Commit

Permalink
Fixed config flow error
Browse files Browse the repository at this point in the history
  • Loading branch information
rainepretorius committed Oct 24, 2023
1 parent 4291265 commit 48161b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 41 deletions.
45 changes: 6 additions & 39 deletions custom_components/olarm_sensors/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncio
from typing import Any

from .olarm_api import OlarmSetupApi # type: ignore[import-untyped]
from olarm_api_rainepretorius import OlarmSetupApi # type: ignore[import-untyped]
import voluptuous as vol # type: ignore[import-untyped]

from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
Expand Down Expand Up @@ -39,7 +39,7 @@ async def _show_setup_form(self, errors=None):

async def async_step_user(self, user_input=None) -> FlowResult:
"""Handle the initial step."""
errors: dict = {str: Any}
errors: dict[str, Any] = {}

if user_input is None:
return await self._show_setup_form()
Expand Down Expand Up @@ -113,7 +113,6 @@ async def async_step_user(self, user_input=None) -> FlowResult:
CONF_DEVICE_FIRMWARE: firmware,
CONF_ALARM_CODE: alarm_code,
CONF_OLARM_DEVICES: setup_devices,
OLARM_DEVICES: json,
OLARM_DEVICE_AMOUNT: len(json),
OLARM_DEVICE_NAMES: setup_devices,
},
Expand Down Expand Up @@ -159,27 +158,13 @@ def _get_schema(self):
{
vol.Required(
CONF_API_KEY,
msg="The api key for your account.",
description={
"suggested_value": "Your Olarm API key",
"description": "API key for accessing the Olarm API. You can find your API key here: https://user.olarm.co/#/api",
},
): cv.string,
vol.Required(
CONF_SCAN_INTERVAL,
msg="The update interval in seconds.",
description={
"suggested_value": 10,
"description": "Interval, in seconds, at which to scan the Olarm device for sensor data. Minimum value is 5 seconds.",
},
CONF_SCAN_INTERVAL
): vol.All(vol.Coerce(int), vol.Range(min=5)),
vol.Optional(
CONF_ALARM_CODE,
msg="The code for alarm actions. Leave default for no code.",
description={
"suggested_value": "1234567890",
"description": "Alarm Panel Code",
},
default="1234567890"
): cv.string,
}
)
Expand Down Expand Up @@ -212,34 +197,16 @@ def _get_schema(self):
{
vol.Required(
CONF_API_KEY,
msg="The api key for your account.",
description={
"suggested_value": self.config_entry.data[CONF_API_KEY],
"description": "API key for accessing the Olarm API. You can find your API key here: https://user.olarm.co/#/api",
},
): cv.string,
vol.Required(
CONF_SCAN_INTERVAL,
msg="The update interval in seconds.",
description={
"suggested_value": self.config_entry.data[CONF_SCAN_INTERVAL],
"description": "Interval, in seconds, at which to scan the Olarm device for sensor data. Minimum value is 5 seconds.",
},
): vol.All(vol.Coerce(int), vol.Range(min=5)),
vol.Optional(
CONF_ALARM_CODE,
msg="The code for alarm actions. Leave default for no code.",
description={
"suggested_value": alarm_code,
"description": "Alarm Panel Code",
},
default=alarm_code
): cv.string,
vol.Optional(
CONF_OLARM_DEVICES,
msg="The Olarm devices to load into this Home Assistant instance.",
description={
"description": "The Olarm devices to load into this Home Assistant instance.",
},
): cv.multi_select(self.config_entry.data[OLARM_DEVICE_NAMES]),
}
)
Expand Down Expand Up @@ -268,4 +235,4 @@ async def async_step_init(
return self.async_show_form(
step_id="init",
data_schema=self._get_schema(),
)
)
2 changes: 1 addition & 1 deletion custom_components/olarm_sensors/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
STATE_ALARM_TRIGGERED,
)

VERSION = "2.2.5"
VERSION = "2.2.6"
DOMAIN = "olarm_sensors"
AUTHENTICATION_ERROR = "invalid_credentials"
LOGGER = logging.getLogger(__package__)
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "Integration for Olarm devices",
"domains": ["binary_sensor", "alarm_control_panel", "button", "switch"],
"documentation": "https://github.com/rainepretorius/olarm-ha-integration/blob/main/README.md",
"version": "2.2.5",
"version": "2.2.6",
"iot_class": "cloud_push"
}

0 comments on commit 48161b8

Please sign in to comment.