Refactor Shelly wrapper to coordinator (#79628)
This commit is contained in:
parent
4d3d22320f
commit
22c68b95bf
14 changed files with 336 additions and 321 deletions
|
@ -8,7 +8,7 @@ from homeassistant.const import ATTR_DEVICE_ID
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.typing import EventType
|
||||
|
||||
from . import get_block_device_wrapper, get_rpc_device_wrapper
|
||||
from . import get_block_device_coordinator, get_rpc_device_coordinator
|
||||
from .const import (
|
||||
ATTR_CHANNEL,
|
||||
ATTR_CLICK_TYPE,
|
||||
|
@ -37,15 +37,15 @@ def async_describe_events(
|
|||
input_name = f"{event.data[ATTR_DEVICE]} channel {channel}"
|
||||
|
||||
if click_type in RPC_INPUTS_EVENTS_TYPES:
|
||||
rpc_wrapper = get_rpc_device_wrapper(hass, device_id)
|
||||
if rpc_wrapper and rpc_wrapper.device.initialized:
|
||||
rpc_coordinator = get_rpc_device_coordinator(hass, device_id)
|
||||
if rpc_coordinator and rpc_coordinator.device.initialized:
|
||||
key = f"input:{channel-1}"
|
||||
input_name = get_rpc_entity_name(rpc_wrapper.device, key)
|
||||
input_name = get_rpc_entity_name(rpc_coordinator.device, key)
|
||||
|
||||
elif click_type in BLOCK_INPUTS_EVENTS_TYPES:
|
||||
block_wrapper = get_block_device_wrapper(hass, device_id)
|
||||
if block_wrapper and block_wrapper.device.initialized:
|
||||
device_name = get_block_device_name(block_wrapper.device)
|
||||
block_coordinator = get_block_device_coordinator(hass, device_id)
|
||||
if block_coordinator and block_coordinator.device.initialized:
|
||||
device_name = get_block_device_name(block_coordinator.device)
|
||||
input_name = f"{device_name} channel {channel}"
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue