Add SmartThings button support via events (#20707)
* Add event support for buttons * binary_sensor test clean-up
This commit is contained in:
1 parent
3553d26f6b
commit
38ea43b678
5 files changed
+82
-19
No files matched your search
@@ -19,7 +19,7 @@ from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
from .config_flow import SmartThingsFlowHandler # noqa
|
||||
from .const import (
|
||||
CONF_APP_ID, CONF_INSTALLED_APP_ID, DATA_BROKERS, DATA_MANAGER, DOMAIN,
|
||||
SIGNAL_SMARTTHINGS_UPDATE, SUPPORTED_PLATFORMS)
|
||||
EVENT_BUTTON, SIGNAL_SMARTTHINGS_UPDATE, SUPPORTED_PLATFORMS)
|
||||
from .smartapp import (
|
||||
setup_smartapp, setup_smartapp_endpoint, validate_installed_app)
|
||||
|
||||
@@ -154,6 +154,19 @@ class DeviceBroker:
|
||||
continue
|
||||
device.status.apply_attribute_update(
|
||||
evt.component_id, evt.capability, evt.attribute, evt.value)
|
||||
|
||||
# Fire events for buttons
|
||||
if evt.capability == 'button' and evt.attribute == 'button':
|
||||
data = {
|
||||
'component_id': evt.component_id,
|
||||
'device_id': evt.device_id,
|
||||
'location_id': evt.location_id,
|
||||
'value': evt.value,
|
||||
'name': device.label
|
||||
}
|
||||
self._hass.bus.async_fire(EVENT_BUTTON, data)
|
||||
_LOGGER.debug("Fired button event: %s", data)
|
||||
|
||||
updated_devices.add(device.device_id)
|
||||
_LOGGER.debug("Update received with %s events and updated %s devices",
|
||||
len(req.events), len(updated_devices))
|
||||
|
||||
Reference in new issue
Block a user