From e1e018a336d17f619246d62734516843dbf49b0f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:51:57 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../alarmdotcom/alarm_control_panel.py | 6 +- custom_components/alarmdotcom/base_device.py | 14 +-- custom_components/alarmdotcom/config_flow.py | 114 ++++++++---------- custom_components/alarmdotcom/manifest.json | 5 +- 4 files changed, 64 insertions(+), 75 deletions(-) diff --git a/custom_components/alarmdotcom/alarm_control_panel.py b/custom_components/alarmdotcom/alarm_control_panel.py index 86bee18..9eba9b5 100644 --- a/custom_components/alarmdotcom/alarm_control_panel.py +++ b/custom_components/alarmdotcom/alarm_control_panel.py @@ -124,7 +124,11 @@ def state(self) -> str | None: match self._device.desired_state: case libPartition.DeviceState.DISARMED: return str(STATE_ALARM_DISARMING) - case libPartition.DeviceState.ARMED_STAY | libPartition.DeviceState.ARMED_AWAY | libPartition.DeviceState.ARMED_NIGHT: + case ( + libPartition.DeviceState.ARMED_STAY + | libPartition.DeviceState.ARMED_AWAY + | libPartition.DeviceState.ARMED_NIGHT + ): return str(STATE_ALARM_ARMING) LOGGER.error( diff --git a/custom_components/alarmdotcom/base_device.py b/custom_components/alarmdotcom/base_device.py index ce96ab0..2f956c5 100644 --- a/custom_components/alarmdotcom/base_device.py +++ b/custom_components/alarmdotcom/base_device.py @@ -51,14 +51,12 @@ def __init__( self._attr_extra_state_attributes: MutableMapping[str, Any] = {} - self._attr_device_info = DeviceInfo( - { - "manufacturer": "Alarm.com", - "name": device.name, - "identifiers": {(DOMAIN, self._adc_id)}, - "via_device": (DOMAIN, self._device.partition_id), - } - ) + self._attr_device_info = DeviceInfo({ + "manufacturer": "Alarm.com", + "name": device.name, + "identifiers": {(DOMAIN, self._adc_id)}, + "via_device": (DOMAIN, self._device.partition_id), + }) @property def device_type_name(self) -> str: diff --git a/custom_components/alarmdotcom/config_flow.py b/custom_components/alarmdotcom/config_flow.py index 718b9b8..2d13b44 100644 --- a/custom_components/alarmdotcom/config_flow.py +++ b/custom_components/alarmdotcom/config_flow.py @@ -133,16 +133,14 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Flo else: return await self.async_step_final() - creds_schema = vol.Schema( - { - vol.Required(CONF_USERNAME): TextSelector( - TextSelectorConfig(type=TextSelectorType.TEXT, autocomplete="username") - ), - vol.Required(CONF_PASSWORD): TextSelector( - TextSelectorConfig(type=TextSelectorType.PASSWORD, autocomplete="current-password") - ), - } - ) + creds_schema = vol.Schema({ + vol.Required(CONF_USERNAME): TextSelector( + TextSelectorConfig(type=TextSelectorType.TEXT, autocomplete="username") + ), + vol.Required(CONF_PASSWORD): TextSelector( + TextSelectorConfig(type=TextSelectorType.PASSWORD, autocomplete="current-password") + ), + }) return self.async_show_form(step_id="user", data_schema=creds_schema, errors=errors, last_step=False) @@ -176,17 +174,15 @@ async def async_step_otp_select_method(self, user_input: dict[str, Any] | None = ) errors["base"] = "cannot_connect" - otp_method_schema = vol.Schema( - { - vol.Required(CONF_OTP_METHOD, default=self._enabled_otp_methods[0].name): SelectSelector( - SelectSelectorConfig( - options=[otp_type.name for otp_type in self._enabled_otp_methods], - mode=SelectSelectorMode.DROPDOWN, - translation_key=CONF_OTP_METHODS_LIST, - ) - ), - } - ) + otp_method_schema = vol.Schema({ + vol.Required(CONF_OTP_METHOD, default=self._enabled_otp_methods[0].name): SelectSelector( + SelectSelectorConfig( + options=[otp_type.name for otp_type in self._enabled_otp_methods], + mode=SelectSelectorMode.DROPDOWN, + translation_key=CONF_OTP_METHODS_LIST, + ) + ), + }) return self.async_show_form( step_id="otp_select_method", data_schema=otp_method_schema, errors=errors, last_step=False @@ -229,13 +225,11 @@ async def async_step_otp_submit(self, user_input: dict[str, Any] | None = None) else: return await self.async_step_final() - creds_schema = vol.Schema( - { - vol.Required(CONF_OTP): TextSelector( - TextSelectorConfig(type=TextSelectorType.TEXT, autocomplete="one-time-code") - ), - } - ) + creds_schema = vol.Schema({ + vol.Required(CONF_OTP): TextSelector( + TextSelectorConfig(type=TextSelectorType.TEXT, autocomplete="one-time-code") + ), + }) return self.async_show_form(step_id="otp_submit", data_schema=creds_schema, errors=errors, last_step=True) @@ -296,25 +290,23 @@ async def async_step_init(self, user_input: dict[str, Any] | None = None) -> Flo self.options.update(user_input) return await self.async_step_modes() - schema = vol.Schema( - { - vol.Optional( - CONF_ARM_CODE, - default=("" if not (arm_code_raw := self.options.get(CONF_ARM_CODE)) else arm_code_raw), - ): selector.selector({"text": {"type": "password"}}), - vol.Required( - CONF_UPDATE_INTERVAL, - default=self.options.get(CONF_UPDATE_INTERVAL, CONF_DEFAULT_UPDATE_INTERVAL_SECONDS), - ): selector.selector( - { - "number": { - "mode": "box", - CONF_UNIT_OF_MEASUREMENT: "seconds", - } + schema = vol.Schema({ + vol.Optional( + CONF_ARM_CODE, + default=("" if not (arm_code_raw := self.options.get(CONF_ARM_CODE)) else arm_code_raw), + ): selector.selector({"text": {"type": "password"}}), + vol.Required( + CONF_UPDATE_INTERVAL, + default=self.options.get(CONF_UPDATE_INTERVAL, CONF_DEFAULT_UPDATE_INTERVAL_SECONDS), + ): selector.selector( + { + "number": { + "mode": "box", + CONF_UNIT_OF_MEASUREMENT: "seconds", } - ), - } - ) + } + ), + }) return self.async_show_form( step_id="init", @@ -331,22 +323,20 @@ async def async_step_modes(self, user_input: dict[str, Any] | None = None) -> Fl self.options.update(user_input) return self.async_create_entry(title="", data=self.options) - schema = vol.Schema( - { - vol.Required( - CONF_ARM_HOME, - default=self.options.get(CONF_ARM_HOME, CONF_OPTIONS_DEFAULT[CONF_ARM_HOME]), - ): cv.multi_select(CONF_ARM_MODE_OPTIONS), - vol.Required( - CONF_ARM_AWAY, - default=self.options.get(CONF_ARM_AWAY, CONF_OPTIONS_DEFAULT[CONF_ARM_AWAY]), - ): cv.multi_select(CONF_ARM_MODE_OPTIONS), - vol.Required( - CONF_ARM_NIGHT, - default=self.options.get(CONF_ARM_NIGHT, CONF_OPTIONS_DEFAULT[CONF_ARM_NIGHT]), - ): cv.multi_select(CONF_ARM_MODE_OPTIONS), - } - ) + schema = vol.Schema({ + vol.Required( + CONF_ARM_HOME, + default=self.options.get(CONF_ARM_HOME, CONF_OPTIONS_DEFAULT[CONF_ARM_HOME]), + ): cv.multi_select(CONF_ARM_MODE_OPTIONS), + vol.Required( + CONF_ARM_AWAY, + default=self.options.get(CONF_ARM_AWAY, CONF_OPTIONS_DEFAULT[CONF_ARM_AWAY]), + ): cv.multi_select(CONF_ARM_MODE_OPTIONS), + vol.Required( + CONF_ARM_NIGHT, + default=self.options.get(CONF_ARM_NIGHT, CONF_OPTIONS_DEFAULT[CONF_ARM_NIGHT]), + ): cv.multi_select(CONF_ARM_MODE_OPTIONS), + }) return self.async_show_form( step_id="modes", diff --git a/custom_components/alarmdotcom/manifest.json b/custom_components/alarmdotcom/manifest.json index 4b6fedb..5981c88 100644 --- a/custom_components/alarmdotcom/manifest.json +++ b/custom_components/alarmdotcom/manifest.json @@ -8,9 +8,6 @@ "integration_type": "hub", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/pyalarmdotcom/alarmdotcom/issues", - "requirements": [ - "beautifulsoup4>=4.10.0", - "pyalarmdotcomajax==0.5.10" - ], + "requirements": ["beautifulsoup4>=4.10.0", "pyalarmdotcomajax==0.5.10"], "version": "3.0.10" }