Skip to content

Commit

Permalink
fix: add callback decorator to handle_state_change (#365)
Browse files Browse the repository at this point in the history
* fix: add `callback` decorator to `handle_state_change`

* formatting

* linting

* more linting
  • Loading branch information
firstof9 authored May 14, 2024
1 parent 1209209 commit 6164f55
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
13 changes: 5 additions & 8 deletions custom_components/keymaster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
from homeassistant.const import (
ATTR_ENTITY_ID,
EVENT_HOMEASSISTANT_STARTED,
STATE_LOCKED,
STATE_ON,
STATE_UNLOCKED,
)
from homeassistant.core import Config, CoreState, Event, HomeAssistant, ServiceCall
from homeassistant.helpers.dispatcher import async_dispatcher_send
Expand Down Expand Up @@ -107,7 +105,7 @@
async def homeassistant_started_listener(
hass: HomeAssistant,
config_entry: ConfigEntry,
locks_to_watch: List[KeymasterLock],
locks_to_watch: List[KeymasterLock], # pylint: disable-next=unused-argument
evt: Event = None,
):
"""Start tracking state changes after HomeAssistant has started."""
Expand All @@ -121,7 +119,9 @@ async def homeassistant_started_listener(
)


async def async_setup(hass: HomeAssistant, config: Config) -> bool:
async def async_setup( # pylint: disable-next=unused-argument
hass: HomeAssistant, config: Config
) -> bool:
"""Disallow configuration via YAML."""
return True

Expand All @@ -130,7 +130,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
"""Set up is called when Home Assistant is loading our component."""
hass.data.setdefault(DOMAIN, {})
_LOGGER.info(
"Version %s is starting, if you have any issues please report" " them here: %s",
"Version %s is starting, if you have any issues please report them here: %s",
VERSION,
ISSUE_URL,
)
Expand Down Expand Up @@ -482,8 +482,6 @@ async def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> Non
hass,
[lock.lock_entity_id for lock in locks_to_watch],
functools.partial(handle_state_change, hass, config_entry),
from_state=[STATE_LOCKED, STATE_UNLOCKED],
to_state=[STATE_LOCKED, STATE_UNLOCKED],
)
)

Expand Down Expand Up @@ -577,7 +575,6 @@ async def async_update_usercodes(self) -> Dict[Union[str, int], Any]:
async def _async_update(self) -> Dict[Union[str, int], Any]:
"""Update usercodes."""
# loop to get user code data from entity_id node
instance_id = 1 # default
data = {CONF_LOCK_ENTITY_ID: self._primary_lock.lock_entity_id}

# # make button call
Expand Down
1 change: 0 additions & 1 deletion custom_components/keymaster/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
999: "Kwikset",
0: "No Status Reported",
9: "Lock Jammed",
16: "User Access", # FE599 code
17: "Keypad Lock Jammed",
21: "Manual Lock",
22: "Manual Unlock",
Expand Down
1 change: 1 addition & 0 deletions custom_components/keymaster/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def handle_zwave_js_event(hass: HomeAssistant, config_entry: ConfigEntry, evt: E
return


@callback
def handle_state_change(
hass: HomeAssistant,
config_entry: ConfigEntry,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/keymaster/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def call_service(
raise err


async def refresh_codes(
async def refresh_codes( # pylint: disable-next=unused-argument
hass: HomeAssistant, entity_id: str, instance_id: int = 1
) -> None:
"""Refresh lock codes."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/keymaster/system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@callback
def async_register(
def async_register( # pylint: disable-next=unused-argument
hass: HomeAssistant, register: system_health.SystemHealthRegistration
) -> None:
"""Register system health callbacks."""
Expand Down
3 changes: 2 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pydispatcher
zeroconf
tox
mypy
flake8
flake8
pylint

0 comments on commit 6164f55

Please sign in to comment.