Update dependencies to receive data on webhook callbacks (#21838)
parent
f3e8e34089
commit
39749952ee
|
@ -27,7 +27,7 @@ from .smartapp import (
|
||||||
setup_smartapp, setup_smartapp_endpoint, smartapp_sync_subscriptions,
|
setup_smartapp, setup_smartapp_endpoint, smartapp_sync_subscriptions,
|
||||||
validate_installed_app)
|
validate_installed_app)
|
||||||
|
|
||||||
REQUIREMENTS = ['pysmartapp==0.3.0', 'pysmartthings==0.6.3']
|
REQUIREMENTS = ['pysmartapp==0.3.1', 'pysmartthings==0.6.7']
|
||||||
DEPENDENCIES = ['webhook']
|
DEPENDENCIES = ['webhook']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -290,7 +290,8 @@ class DeviceBroker:
|
||||||
if not device:
|
if not device:
|
||||||
continue
|
continue
|
||||||
device.status.apply_attribute_update(
|
device.status.apply_attribute_update(
|
||||||
evt.component_id, evt.capability, evt.attribute, evt.value)
|
evt.component_id, evt.capability, evt.attribute, evt.value,
|
||||||
|
data=evt.data)
|
||||||
|
|
||||||
# Fire events for buttons
|
# Fire events for buttons
|
||||||
if evt.capability == Capability.button and \
|
if evt.capability == Capability.button and \
|
||||||
|
@ -300,7 +301,8 @@ class DeviceBroker:
|
||||||
'device_id': evt.device_id,
|
'device_id': evt.device_id,
|
||||||
'location_id': evt.location_id,
|
'location_id': evt.location_id,
|
||||||
'value': evt.value,
|
'value': evt.value,
|
||||||
'name': device.label
|
'name': device.label,
|
||||||
|
'data': evt.data
|
||||||
}
|
}
|
||||||
self._hass.bus.async_fire(EVENT_BUTTON, data)
|
self._hass.bus.async_fire(EVENT_BUTTON, data)
|
||||||
_LOGGER.debug("Fired button event: %s", data)
|
_LOGGER.debug("Fired button event: %s", data)
|
||||||
|
@ -312,6 +314,7 @@ class DeviceBroker:
|
||||||
'capability': evt.capability,
|
'capability': evt.capability,
|
||||||
'attribute': evt.attribute,
|
'attribute': evt.attribute,
|
||||||
'value': evt.value,
|
'value': evt.value,
|
||||||
|
'data': evt.data
|
||||||
}
|
}
|
||||||
_LOGGER.debug("Push update received: %s", data)
|
_LOGGER.debug("Push update received: %s", data)
|
||||||
|
|
||||||
|
|
|
@ -1256,10 +1256,10 @@ pysher==1.0.1
|
||||||
pysma==0.3.1
|
pysma==0.3.1
|
||||||
|
|
||||||
# homeassistant.components.smartthings
|
# homeassistant.components.smartthings
|
||||||
pysmartapp==0.3.0
|
pysmartapp==0.3.1
|
||||||
|
|
||||||
# homeassistant.components.smartthings
|
# homeassistant.components.smartthings
|
||||||
pysmartthings==0.6.3
|
pysmartthings==0.6.7
|
||||||
|
|
||||||
# homeassistant.components.device_tracker.snmp
|
# homeassistant.components.device_tracker.snmp
|
||||||
# homeassistant.components.sensor.snmp
|
# homeassistant.components.sensor.snmp
|
||||||
|
|
|
@ -224,10 +224,10 @@ pyps4-homeassistant==0.3.0
|
||||||
pyqwikswitch==0.8
|
pyqwikswitch==0.8
|
||||||
|
|
||||||
# homeassistant.components.smartthings
|
# homeassistant.components.smartthings
|
||||||
pysmartapp==0.3.0
|
pysmartapp==0.3.1
|
||||||
|
|
||||||
# homeassistant.components.smartthings
|
# homeassistant.components.smartthings
|
||||||
pysmartthings==0.6.3
|
pysmartthings==0.6.7
|
||||||
|
|
||||||
# homeassistant.components.sonos
|
# homeassistant.components.sonos
|
||||||
pysonos==0.0.8
|
pysonos==0.0.8
|
||||||
|
|
|
@ -326,7 +326,7 @@ def scene_fixture(scene_factory):
|
||||||
def event_factory_fixture():
|
def event_factory_fixture():
|
||||||
"""Fixture for creating mock devices."""
|
"""Fixture for creating mock devices."""
|
||||||
def _factory(device_id, event_type="DEVICE_EVENT", capability='',
|
def _factory(device_id, event_type="DEVICE_EVENT", capability='',
|
||||||
attribute='Updated', value='Value'):
|
attribute='Updated', value='Value', data=None):
|
||||||
event = Mock()
|
event = Mock()
|
||||||
event.event_type = event_type
|
event.event_type = event_type
|
||||||
event.device_id = device_id
|
event.device_id = device_id
|
||||||
|
@ -334,6 +334,7 @@ def event_factory_fixture():
|
||||||
event.capability = capability
|
event.capability = capability
|
||||||
event.attribute = attribute
|
event.attribute = attribute
|
||||||
event.value = value
|
event.value = value
|
||||||
|
event.data = data
|
||||||
event.location_id = str(uuid4())
|
event.location_id = str(uuid4())
|
||||||
return event
|
return event
|
||||||
return _factory
|
return _factory
|
||||||
|
|
|
@ -235,16 +235,21 @@ async def test_broker_regenerates_token(
|
||||||
|
|
||||||
|
|
||||||
async def test_event_handler_dispatches_updated_devices(
|
async def test_event_handler_dispatches_updated_devices(
|
||||||
hass, config_entry, device_factory, event_request_factory):
|
hass, config_entry, device_factory, event_request_factory,
|
||||||
|
event_factory):
|
||||||
"""Test the event handler dispatches updated devices."""
|
"""Test the event handler dispatches updated devices."""
|
||||||
devices = [
|
devices = [
|
||||||
device_factory('Bedroom 1 Switch', ['switch']),
|
device_factory('Bedroom 1 Switch', ['switch']),
|
||||||
device_factory('Bathroom 1', ['switch']),
|
device_factory('Bathroom 1', ['switch']),
|
||||||
device_factory('Sensor', ['motionSensor']),
|
device_factory('Sensor', ['motionSensor']),
|
||||||
|
device_factory('Lock', ['lock'])
|
||||||
]
|
]
|
||||||
device_ids = [devices[0].device_id, devices[1].device_id,
|
device_ids = [devices[0].device_id, devices[1].device_id,
|
||||||
devices[2].device_id]
|
devices[2].device_id, devices[3].device_id]
|
||||||
request = event_request_factory(device_ids)
|
event = event_factory(devices[3].device_id, capability='lock',
|
||||||
|
attribute='lock', value='locked',
|
||||||
|
data={'codeId': '1'})
|
||||||
|
request = event_request_factory(device_ids=device_ids, events=[event])
|
||||||
config_entry.data[CONF_INSTALLED_APP_ID] = request.installed_app_id
|
config_entry.data[CONF_INSTALLED_APP_ID] = request.installed_app_id
|
||||||
called = False
|
called = False
|
||||||
|
|
||||||
|
@ -265,6 +270,8 @@ async def test_event_handler_dispatches_updated_devices(
|
||||||
assert called
|
assert called
|
||||||
for device in devices:
|
for device in devices:
|
||||||
assert device.status.values['Updated'] == 'Value'
|
assert device.status.values['Updated'] == 'Value'
|
||||||
|
assert devices[3].status.attributes['lock'].value == 'locked'
|
||||||
|
assert devices[3].status.attributes['lock'].data == {'codeId': '1'}
|
||||||
|
|
||||||
|
|
||||||
async def test_event_handler_ignores_other_installed_app(
|
async def test_event_handler_ignores_other_installed_app(
|
||||||
|
@ -308,7 +315,8 @@ async def test_event_handler_fires_button_events(
|
||||||
'device_id': device.device_id,
|
'device_id': device.device_id,
|
||||||
'location_id': event.location_id,
|
'location_id': event.location_id,
|
||||||
'value': 'pushed',
|
'value': 'pushed',
|
||||||
'name': device.label
|
'name': device.label,
|
||||||
|
'data': None
|
||||||
}
|
}
|
||||||
hass.bus.async_listen(EVENT_BUTTON, handler)
|
hass.bus.async_listen(EVENT_BUTTON, handler)
|
||||||
broker = smartthings.DeviceBroker(
|
broker = smartthings.DeviceBroker(
|
||||||
|
|
Loading…
Reference in New Issue