Add support for custom configurations in ZHA (#48423)
* initial configuration options * first crack at saving the data * constants * implement initial options * make more dynamic * fix unload and reload of the config entry * update unload
This commit is contained in:
parent
9c11f6547a
commit
fe80afdb86
7 changed files with 142 additions and 12 deletions
|
@ -24,7 +24,14 @@ import zigpy.zdo.types as zdo_types
|
|||
|
||||
from homeassistant.core import State, callback
|
||||
|
||||
from .const import CLUSTER_TYPE_IN, CLUSTER_TYPE_OUT, DATA_ZHA, DATA_ZHA_GATEWAY
|
||||
from .const import (
|
||||
CLUSTER_TYPE_IN,
|
||||
CLUSTER_TYPE_OUT,
|
||||
CUSTOM_CONFIGURATION,
|
||||
DATA_ZHA,
|
||||
DATA_ZHA_GATEWAY,
|
||||
ZHA_OPTIONS,
|
||||
)
|
||||
from .registries import BINDABLE_CLUSTERS
|
||||
from .typing import ZhaDeviceType, ZigpyClusterType
|
||||
|
||||
|
@ -122,6 +129,16 @@ def async_is_bindable_target(source_zha_device, target_zha_device):
|
|||
return False
|
||||
|
||||
|
||||
@callback
|
||||
def async_get_zha_config_value(config_entry, config_key, default):
|
||||
"""Get the value for the specified configuration from the zha config entry."""
|
||||
return (
|
||||
config_entry.options.get(CUSTOM_CONFIGURATION, {})
|
||||
.get(ZHA_OPTIONS, {})
|
||||
.get(config_key, default)
|
||||
)
|
||||
|
||||
|
||||
async def async_get_zha_device(hass, device_id):
|
||||
"""Get a ZHA device for the given device registry id."""
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue