Skip to content

Commit

Permalink
Handle missing config entry gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
monty68 committed Dec 3, 2024
1 parent 1e0a34d commit b41a7be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions custom_components/uniled/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,15 @@ async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Manage the options."""
self.coordinator: UniledUpdateCoordinator = self.hass.data[DOMAIN][
self.config_entry.entry_id
]

if self.config_entry.entry_id in self.hass.data[DOMAIN]:
self.coordinator: UniledUpdateCoordinator = self.hass.data[DOMAIN][self.config_entry.entry_id]
else:
return self.async_abort(reason="unknown")

#self.coordinator: UniledUpdateCoordinator = self.hass.data[DOMAIN][
# self.config_entry.entry_id
#]

if self.config_entry.data.get(CONF_TRANSPORT) == UNILED_TRANSPORT_ZNG:
self._mesh_set_context()
Expand Down
3 changes: 2 additions & 1 deletion custom_components/uniled/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
"mesh_not_supported": "Mesh not supported.",
"no_devices_found": "No devices found on the network.",
"no_response": "No response from device.",
"not_supported": "Device not supported."
"not_supported": "Device not supported.",
"unknown": "Unexpected error!"
},
"error": {
"cannot_connect": "Failed to connect!",
Expand Down

0 comments on commit b41a7be

Please sign in to comment.