Skip to content

Commit

Permalink
Make the new option available only for lock pro entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal4K committed Aug 22, 2024
1 parent 9370325 commit b7f7932
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions homeassistant/components/switchbot/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
SwitchbotApiError,
SwitchbotAuthenticationError,
SwitchbotLock,
SwitchbotModel,
parse_advertisement_data,
)
import voluptuous as vol
Expand Down Expand Up @@ -357,19 +358,24 @@ async def async_step_init(
# Update common entity options for all other entities.
return self.async_create_entry(title="", data=user_input)

options = {
options: dict[vol.Optional, Any] = {
vol.Optional(
CONF_RETRY_COUNT,
default=self.config_entry.options.get(
CONF_RETRY_COUNT, DEFAULT_RETRY_COUNT
),
): int,
vol.Optional(
CONF_LOCK_NIGHTLATCH,
default=self.config_entry.options.get(
CONF_LOCK_NIGHTLATCH, DEFAULT_LOCK_NIGHTLATCH
),
): bool,
): int
}
if self.config_entry.runtime_data.model == SwitchbotModel.LOCK_PRO:
options.update(
{
vol.Optional(
CONF_LOCK_NIGHTLATCH,
default=self.config_entry.options.get(
CONF_LOCK_NIGHTLATCH, DEFAULT_LOCK_NIGHTLATCH
),
): bool
}
)

return self.async_show_form(step_id="init", data_schema=vol.Schema(options))

0 comments on commit b7f7932

Please sign in to comment.