Allow initialized callback to have arguments (#58129)

This commit is contained in:
Pieter Mulder 2021-10-28 22:14:50 +02:00 committed by GitHub
parent 0f25900309
commit b368476429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,10 @@
"""Support for HDMI CEC.""" """Support for HDMI CEC."""
from __future__ import annotations from __future__ import annotations
from functools import partial, reduce from functools import reduce
import logging import logging
import multiprocessing import multiprocessing
from typing import Any
from pycec.cec import CecAdapter from pycec.cec import CecAdapter
from pycec.commands import CecCommand, KeyPressCommand, KeyReleaseCommand from pycec.commands import CecCommand, KeyPressCommand, KeyReleaseCommand
@ -41,7 +42,7 @@ from homeassistant.const import (
STATE_PLAYING, STATE_PLAYING,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import discovery, event from homeassistant.helpers import discovery, event
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
@ -222,9 +223,12 @@ def setup(hass: HomeAssistant, base_config: ConfigType) -> bool: # noqa: C901
hass.bus.fire(EVENT_HDMI_CEC_UNAVAILABLE) hass.bus.fire(EVENT_HDMI_CEC_UNAVAILABLE)
adapter.init() adapter.init()
hdmi_network.set_initialized_callback( @callback
partial(event.async_call_later, hass, WATCHDOG_INTERVAL, _adapter_watchdog) def _async_initialized_callback(*_: Any):
) """Add watchdog on initialization."""
return event.async_call_later(hass, WATCHDOG_INTERVAL, _adapter_watchdog)
hdmi_network.set_initialized_callback(_async_initialized_callback)
def _volume(call): def _volume(call):
"""Increase/decrease volume and mute/unmute system.""" """Increase/decrease volume and mute/unmute system."""