Allow initialized callback to have arguments (#58129)

pull/58643/head
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
1 changed files with 9 additions and 5 deletions

View File

@ -1,9 +1,10 @@
"""Support for HDMI CEC."""
from __future__ import annotations
from functools import partial, reduce
from functools import reduce
import logging
import multiprocessing
from typing import Any
from pycec.cec import CecAdapter
from pycec.commands import CecCommand, KeyPressCommand, KeyReleaseCommand
@ -41,7 +42,7 @@ from homeassistant.const import (
STATE_PLAYING,
STATE_UNAVAILABLE,
)
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import discovery, event
import homeassistant.helpers.config_validation as cv
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)
adapter.init()
hdmi_network.set_initialized_callback(
partial(event.async_call_later, hass, WATCHDOG_INTERVAL, _adapter_watchdog)
)
@callback
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):
"""Increase/decrease volume and mute/unmute system."""