Skip to content

Commit

Permalink
Fix UI issue (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 authored Mar 24, 2024
1 parent d343f72 commit e20935b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions custom_components/lock_code_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
f"Unable to start because lock {entity_id} can't be found"
)

hass.data.setdefault(DOMAIN, {CONF_LOCKS: {}, COORDINATORS: {}, "resources": False})
hass.data[DOMAIN][entry_id] = {
CONF_LOCKS: {},
COORDINATORS: {},
Expand Down
10 changes: 6 additions & 4 deletions custom_components/lock_code_manager/providers/zwave_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import logging
from typing import Callable, Iterable

from zwave_js_server.client import Client
from zwave_js_server.const.command_class.lock import ATTR_CODE_SLOT, ATTR_USERCODE
from zwave_js_server.const.command_class.notification import (
AccessControlNotificationEvent,
Expand Down Expand Up @@ -144,9 +143,12 @@ async def async_unload(self) -> None:

async def async_is_connection_up(self) -> bool:
"""Return whether connection to lock is up."""
client: Client = self.hass.data[ZWAVE_JS_DOMAIN][
self.lock_config_entry.entry_id
][DATA_CLIENT]
if (
client := self.hass.data.get(ZWAVE_JS_DOMAIN, {})
.get(self.lock_config_entry.entry_id, {})
.get(DATA_CLIENT)
) is None:
return False
return (
self.lock_config_entry.state == ConfigEntryState.LOADED
and client.connected
Expand Down

0 comments on commit e20935b

Please sign in to comment.