async def test_device_class_cover(hass, device_class, google_type): """Test that a binary entity syncs to the correct device type.""" sensor = DemoCover(hass, 'Demo Sensor', device_class=device_class) sensor.hass = hass sensor.entity_id = 'cover.demo_sensor' await sensor.async_update_ha_state() result = await sh.async_handle_message( hass, BASIC_CONFIG, 'test-agent', { "requestId": REQ_ID, "inputs": [{ "intent": "action.devices.SYNC" }] }) assert result == { 'requestId': REQ_ID, 'payload': { 'agentUserId': 'test-agent', 'devices': [{ 'attributes': {}, 'id': 'cover.demo_sensor', 'name': { 'name': 'Demo Sensor' }, 'traits': ['action.devices.traits.OpenClose'], 'type': google_type, 'willReportState': False }] } }
async def test_device_class_cover(hass, device_class, google_type): """Test that a binary entity syncs to the correct device type.""" sensor = DemoCover(None, hass, "Demo Sensor", device_class=device_class) sensor.hass = hass sensor.entity_id = "cover.demo_sensor" await sensor.async_update_ha_state() result = await sh.async_handle_message( hass, BASIC_CONFIG, "test-agent", {"requestId": REQ_ID, "inputs": [{"intent": "action.devices.SYNC"}]}, ) assert result == { "requestId": REQ_ID, "payload": { "agentUserId": "test-agent", "devices": [ { "attributes": {}, "id": "cover.demo_sensor", "name": {"name": "Demo Sensor"}, "traits": ["action.devices.traits.OpenClose"], "type": google_type, "willReportState": False, } ], }, }
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the dummy cover platform.""" domain = CONF_COVERS devices = [] _LOGGER.debug("Create dummy %s enties", domain) for entity in hass.data[DOMAIN][domain]: _LOGGER.debug("Create demo %s entity: %s", domain, entity) #class: DemoCover(hass,unique_id,name,position=None,tilt_position=None,device_class=None,supported_features=None) #example: DemoCover(hass, "cover_3", "Living Room Window", 70, 50) devices.append( DemoCover(hass, entity[CONF_ENTITY_ID], entity[CONF_NAME])) add_entities(devices) _LOGGER.debug("setup_platform: %s complete!", domain)