Cleanup - move Shelly logger to const (#68046)
This commit is contained in:
parent
1a79118600
commit
083d51a727
8 changed files with 74 additions and 84 deletions
|
@ -4,8 +4,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from collections.abc import Callable, Mapping
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import Any, Final, cast
|
||||
from typing import Any, cast
|
||||
|
||||
from aioshelly.block_device import Block
|
||||
import async_timeout
|
||||
|
@ -34,6 +33,7 @@ from .const import (
|
|||
BLOCK,
|
||||
DATA_CONFIG_ENTRY,
|
||||
DOMAIN,
|
||||
LOGGER,
|
||||
REST,
|
||||
RPC,
|
||||
RPC_POLL,
|
||||
|
@ -45,8 +45,6 @@ from .utils import (
|
|||
get_rpc_key_instances,
|
||||
)
|
||||
|
||||
_LOGGER: Final = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_entry_attribute_entities(
|
||||
hass: HomeAssistant,
|
||||
|
@ -313,12 +311,12 @@ class ShellyBlockEntity(entity.Entity):
|
|||
|
||||
async def set_state(self, **kwargs: Any) -> Any:
|
||||
"""Set block state (HTTP request)."""
|
||||
_LOGGER.debug("Setting state for entity %s, state: %s", self.name, kwargs)
|
||||
LOGGER.debug("Setting state for entity %s, state: %s", self.name, kwargs)
|
||||
try:
|
||||
async with async_timeout.timeout(AIOSHELLY_DEVICE_TIMEOUT_SEC):
|
||||
return await self.block.set_state(**kwargs)
|
||||
except (asyncio.TimeoutError, OSError) as err:
|
||||
_LOGGER.error(
|
||||
LOGGER.error(
|
||||
"Setting state for entity %s failed, state: %s, error: %s",
|
||||
self.name,
|
||||
kwargs,
|
||||
|
@ -371,7 +369,7 @@ class ShellyRpcEntity(entity.Entity):
|
|||
|
||||
async def call_rpc(self, method: str, params: Any) -> Any:
|
||||
"""Call RPC method."""
|
||||
_LOGGER.debug(
|
||||
LOGGER.debug(
|
||||
"Call RPC for entity %s, method: %s, params: %s",
|
||||
self.name,
|
||||
method,
|
||||
|
@ -381,7 +379,7 @@ class ShellyRpcEntity(entity.Entity):
|
|||
async with async_timeout.timeout(AIOSHELLY_DEVICE_TIMEOUT_SEC):
|
||||
return await self.wrapper.device.call_rpc(method, params)
|
||||
except asyncio.TimeoutError as err:
|
||||
_LOGGER.error(
|
||||
LOGGER.error(
|
||||
"Call RPC for entity %s failed, method: %s, params: %s, error: %s",
|
||||
self.name,
|
||||
method,
|
||||
|
@ -625,6 +623,6 @@ class ShellySleepingBlockAttributeEntity(ShellyBlockAttributeEntity, RestoreEnti
|
|||
self.block = block
|
||||
self.entity_description = description
|
||||
|
||||
_LOGGER.debug("Entity %s attached to block", self.name)
|
||||
LOGGER.debug("Entity %s attached to block", self.name)
|
||||
super()._update_callback()
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue