Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
"""
import logging

from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_send

from . import AttributeListeningChannel
from .. import registries
from ..const import REPORT_CONFIG_ASAP, REPORT_CONFIG_MAX_INT, REPORT_CONFIG_MIN_INT
from ..const import (
REPORT_CONFIG_ASAP,
REPORT_CONFIG_MAX_INT,
REPORT_CONFIG_MIN_INT,
SIGNAL_ATTR_UPDATED,
)


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -38,3 +46,23 @@ class SmartThingsAcceleration(AttributeListeningChannel):
{"attr": "y_axis", "config": REPORT_CONFIG_ASAP},
{"attr": "z_axis", "config": REPORT_CONFIG_ASAP},
]

@callback
def attribute_updated(self, attrid, value):
"""Handle attribute updates on this cluster."""
if attrid == self.value_attribute:
async_dispatcher_send(
self._zha_device.hass, f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", value
)
else:
self.zha_send_event(
self._cluster,
SIGNAL_ATTR_UPDATED,
{
"attribute_id": attrid,
"attribute_name": self._cluster.attributes.get(attrid, ["Unknown"])[
0
],
"value": value,
},
)