Exemple #1
0
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,
                }
            ],
        },
    }
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
            }]
        }
    }