Add debug logging to esphome state updates (#74260)

This commit is contained in:
J. Nick Koston 2022-06-30 12:05:29 -05:00 committed by GitHub
parent 105b1b9d58
commit ce03157f16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
from collections.abc import Callable from collections.abc import Callable
from dataclasses import dataclass, field from dataclasses import dataclass, field
import logging
from typing import Any, cast from typing import Any, cast
from aioesphomeapi import ( from aioesphomeapi import (
@ -36,6 +37,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.storage import Store from homeassistant.helpers.storage import Store
SAVE_DELAY = 120 SAVE_DELAY = 120
_LOGGER = logging.getLogger(__name__)
# Mapping from ESPHome info type to HA platform # Mapping from ESPHome info type to HA platform
INFO_TYPE_TO_PLATFORM: dict[type[EntityInfo], str] = { INFO_TYPE_TO_PLATFORM: dict[type[EntityInfo], str] = {
@ -128,6 +130,12 @@ class RuntimeEntryData:
component_key = self.key_to_component[state.key] component_key = self.key_to_component[state.key]
self.state[component_key][state.key] = state self.state[component_key][state.key] = state
signal = f"esphome_{self.entry_id}_update_{component_key}_{state.key}" signal = f"esphome_{self.entry_id}_update_{component_key}_{state.key}"
_LOGGER.debug(
"Dispatching update for component %s with state key %s: %s",
component_key,
state.key,
state,
)
async_dispatcher_send(hass, signal) async_dispatcher_send(hass, signal)
@callback @callback