Add configuration entities and device actions for Inovelli Blue Series switch to ZHA (#79106)
* Add Inovelli configutation entities to ZHA * add device actions * fix attribute name collision * add device action tests * disable remote protection per Inovelli request * expect_reply to false * update test for expect_reply change * inovelli feedback * translation keys and strings * clean up numbers * prevent double events * remove individual LED defaults per inovelli * redundant check * update test
This commit is contained in:
parent
7042d6d35b
commit
2ed48a9b28
10 changed files with 822 additions and 24 deletions
|
@ -21,6 +21,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from .core import discovery
|
||||
from .core.const import (
|
||||
CHANNEL_IAS_WD,
|
||||
CHANNEL_INOVELLI,
|
||||
CHANNEL_ON_OFF,
|
||||
DATA_ZHA,
|
||||
SIGNAL_ADD_ENTITIES,
|
||||
|
@ -68,7 +69,7 @@ class ZHAEnumSelectEntity(ZhaEntity, SelectEntity):
|
|||
"""Representation of a ZHA select entity."""
|
||||
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
_attr_name: str
|
||||
_attribute: str
|
||||
_enum: type[Enum]
|
||||
|
||||
def __init__(
|
||||
|
@ -79,7 +80,7 @@ class ZHAEnumSelectEntity(ZhaEntity, SelectEntity):
|
|||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Init this select entity."""
|
||||
self._attr_name = self._enum.__name__
|
||||
self._attribute = self._enum.__name__
|
||||
self._attr_options = [entry.name.replace("_", " ") for entry in self._enum]
|
||||
self._channel: ZigbeeChannel = channels[0]
|
||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
|
@ -87,21 +88,21 @@ class ZHAEnumSelectEntity(ZhaEntity, SelectEntity):
|
|||
@property
|
||||
def current_option(self) -> str | None:
|
||||
"""Return the selected entity option to represent the entity state."""
|
||||
option = self._channel.data_cache.get(self._attr_name)
|
||||
option = self._channel.data_cache.get(self._attribute)
|
||||
if option is None:
|
||||
return None
|
||||
return option.name.replace("_", " ")
|
||||
|
||||
async def async_select_option(self, option: str) -> None:
|
||||
"""Change the selected option."""
|
||||
self._channel.data_cache[self._attr_name] = self._enum[option.replace(" ", "_")]
|
||||
self._channel.data_cache[self._attribute] = self._enum[option.replace(" ", "_")]
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def async_restore_last_state(self, last_state) -> None:
|
||||
"""Restore previous state."""
|
||||
if last_state.state and last_state.state != STATE_UNKNOWN:
|
||||
self._channel.data_cache[self._attr_name] = self._enum[
|
||||
self._channel.data_cache[self._attribute] = self._enum[
|
||||
last_state.state.replace(" ", "_")
|
||||
]
|
||||
|
||||
|
@ -285,3 +286,40 @@ class AqaraCurtainMode(ZCLEnumSelectEntity, id_suffix="window_covering_mode"):
|
|||
|
||||
_select_attr = "window_covering_mode"
|
||||
_enum = AqaraE1ReverseDirection
|
||||
|
||||
|
||||
class InovelliOutputMode(types.enum1):
|
||||
"""Inovelli output mode."""
|
||||
|
||||
Dimmer = 0x00
|
||||
OnOff = 0x01
|
||||
|
||||
|
||||
@CONFIG_DIAGNOSTIC_MATCH(
|
||||
channel_names=CHANNEL_INOVELLI,
|
||||
)
|
||||
class InovelliOutputModeEntity(ZCLEnumSelectEntity, id_suffix="output_mode"):
|
||||
"""Inovelli output mode control."""
|
||||
|
||||
_select_attr = "output_mode"
|
||||
_enum = InovelliOutputMode
|
||||
_attr_name: str = "Output mode"
|
||||
|
||||
|
||||
class InovelliSwitchType(types.enum8):
|
||||
"""Inovelli output mode."""
|
||||
|
||||
Load_Only = 0x00
|
||||
Three_Way_Dumb = 0x01
|
||||
Three_Way_AUX = 0x02
|
||||
|
||||
|
||||
@CONFIG_DIAGNOSTIC_MATCH(
|
||||
channel_names=CHANNEL_INOVELLI,
|
||||
)
|
||||
class InovelliSwitchTypeEntity(ZCLEnumSelectEntity, id_suffix="switch_type"):
|
||||
"""Inovelli switch type control."""
|
||||
|
||||
_select_attr = "switch_type"
|
||||
_enum = InovelliSwitchType
|
||||
_attr_name: str = "Switch type"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue