Skip to content

Commit

Permalink
Refactor automation trigger attachment to avoid creating a closure (h…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 19, 2023
1 parent 393544b commit d00934a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions homeassistant/components/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,14 @@ async def async_disable(self, stop_actions: bool = DEFAULT_STOP_ACTIONS) -> None

self.async_write_ha_state()

def _log_callback(self, level: int, msg: str, **kwargs: Any) -> None:
"""Log helper callback."""
self._logger.log(level, "%s %s", msg, self.name, **kwargs)

async def _async_attach_triggers(
self, home_assistant_start: bool
) -> Callable[[], None] | None:
"""Set up the triggers."""

def log_cb(level: int, msg: str, **kwargs: Any) -> None:
self._logger.log(level, "%s %s", msg, self.name, **kwargs)

this = None
self.async_write_ha_state()
if state := self.hass.states.get(self.entity_id):
Expand All @@ -763,7 +763,7 @@ def log_cb(level: int, msg: str, **kwargs: Any) -> None:
self.async_trigger,
DOMAIN,
str(self.name),
log_cb,
self._log_callback,
home_assistant_start,
variables,
)
Expand Down

0 comments on commit d00934a

Please sign in to comment.