diff --git a/homeassistant/components/smartthings/__init__.py b/homeassistant/components/smartthings/__init__.py index 64e717cbc92..88035e3cc79 100644 --- a/homeassistant/components/smartthings/__init__.py +++ b/homeassistant/components/smartthings/__init__.py @@ -27,7 +27,7 @@ from .smartapp import ( setup_smartapp, setup_smartapp_endpoint, smartapp_sync_subscriptions, validate_installed_app) -REQUIREMENTS = ['pysmartapp==0.3.0', 'pysmartthings==0.6.3'] +REQUIREMENTS = ['pysmartapp==0.3.1', 'pysmartthings==0.6.7'] DEPENDENCIES = ['webhook'] _LOGGER = logging.getLogger(__name__) @@ -290,7 +290,8 @@ class DeviceBroker: if not device: continue 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 if evt.capability == Capability.button and \ @@ -300,7 +301,8 @@ class DeviceBroker: 'device_id': evt.device_id, 'location_id': evt.location_id, 'value': evt.value, - 'name': device.label + 'name': device.label, + 'data': evt.data } self._hass.bus.async_fire(EVENT_BUTTON, data) _LOGGER.debug("Fired button event: %s", data) @@ -312,6 +314,7 @@ class DeviceBroker: 'capability': evt.capability, 'attribute': evt.attribute, 'value': evt.value, + 'data': evt.data } _LOGGER.debug("Push update received: %s", data) diff --git a/requirements_all.txt b/requirements_all.txt index 765bf4d0e35..aa1f78ab701 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1256,10 +1256,10 @@ pysher==1.0.1 pysma==0.3.1 # homeassistant.components.smartthings -pysmartapp==0.3.0 +pysmartapp==0.3.1 # homeassistant.components.smartthings -pysmartthings==0.6.3 +pysmartthings==0.6.7 # homeassistant.components.device_tracker.snmp # homeassistant.components.sensor.snmp diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 7f69e2a500a..073768d0cf2 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -224,10 +224,10 @@ pyps4-homeassistant==0.3.0 pyqwikswitch==0.8 # homeassistant.components.smartthings -pysmartapp==0.3.0 +pysmartapp==0.3.1 # homeassistant.components.smartthings -pysmartthings==0.6.3 +pysmartthings==0.6.7 # homeassistant.components.sonos pysonos==0.0.8 diff --git a/tests/components/smartthings/conftest.py b/tests/components/smartthings/conftest.py index 27e833bff25..67c35ba8232 100644 --- a/tests/components/smartthings/conftest.py +++ b/tests/components/smartthings/conftest.py @@ -326,7 +326,7 @@ def scene_fixture(scene_factory): def event_factory_fixture(): """Fixture for creating mock devices.""" def _factory(device_id, event_type="DEVICE_EVENT", capability='', - attribute='Updated', value='Value'): + attribute='Updated', value='Value', data=None): event = Mock() event.event_type = event_type event.device_id = device_id @@ -334,6 +334,7 @@ def event_factory_fixture(): event.capability = capability event.attribute = attribute event.value = value + event.data = data event.location_id = str(uuid4()) return event return _factory diff --git a/tests/components/smartthings/test_init.py b/tests/components/smartthings/test_init.py index ec0b3982517..1f648c7716a 100644 --- a/tests/components/smartthings/test_init.py +++ b/tests/components/smartthings/test_init.py @@ -235,16 +235,21 @@ async def test_broker_regenerates_token( 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.""" devices = [ device_factory('Bedroom 1 Switch', ['switch']), device_factory('Bathroom 1', ['switch']), device_factory('Sensor', ['motionSensor']), + device_factory('Lock', ['lock']) ] device_ids = [devices[0].device_id, devices[1].device_id, - devices[2].device_id] - request = event_request_factory(device_ids) + devices[2].device_id, devices[3].device_id] + 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 called = False @@ -265,6 +270,8 @@ async def test_event_handler_dispatches_updated_devices( assert called for device in devices: 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( @@ -308,7 +315,8 @@ async def test_event_handler_fires_button_events( 'device_id': device.device_id, 'location_id': event.location_id, 'value': 'pushed', - 'name': device.label + 'name': device.label, + 'data': None } hass.bus.async_listen(EVENT_BUTTON, handler) broker = smartthings.DeviceBroker(