Skip to content

Commit 86b0c74

Browse files
committed
get host key from config entry optionally v2
1 parent 1b76d4d commit 86b0c74

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

custom_components/switchbotremote/config_flow.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@
124124

125125

126126
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, Any]:
127-
switchbot = SwitchBot(token=data["token"], secret=data["secret"], host=data["host"])
127+
switchbot = SwitchBot(
128+
token=data["token"],
129+
secret=data["secret"],
130+
host=data.get("host", switchbot_host)
131+
)
128132

129133
try:
130134
remotes = await hass.async_add_executor_job(switchbot.remotes)
@@ -202,7 +206,7 @@ def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
202206
self.sb = SwitchBot(
203207
token=self.data["token"],
204208
secret=self.data["secret"],
205-
host=self.data["host"] or switchbot_host
209+
host=self.data.get("host", switchbot_host)
206210
)
207211
self.discovered_devices = []
208212
self.selected_device = None

0 commit comments

Comments
 (0)