How to use pydeconz - 10 common examples

To help you get started, we’ve selected a few pydeconz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / tests / components / deconz / test_config_flow.py View on Github external
async def test_flow_works(hass, aioclient_mock):
    """Test that config flow works."""
    aioclient_mock.get(
        pydeconz.utils.URL_DISCOVER,
        json=[{"id": "id", "internalipaddress": "1.2.3.4", "internalport": 80}],
        headers={"content-type": "application/json"},
    )
    aioclient_mock.post(
        "http://1.2.3.4:80/api",
        json=[{"success": {"username": "1234567890ABCDEF"}}],
        headers={"content-type": "application/json"},
    )

    result = await hass.config_entries.flow.async_init(
        config_flow.DOMAIN, context={"source": "user"}
    )

    assert result["type"] == "form"
    assert result["step_id"] == "link"
github home-assistant / home-assistant / tests / components / deconz / test_config_flow.py View on Github external
async def test_user_step_manual_configuration_no_bridges_discovered(
    hass, aioclient_mock
):
    """Test config flow with manual input."""
    aioclient_mock.get(
        pydeconz.utils.URL_DISCOVER,
        json=[],
        headers={"content-type": "application/json"},
    )

    result = await hass.config_entries.flow.async_init(
        config_flow.DOMAIN, context={"source": "user"}
    )

    assert result["type"] == "form"
    assert result["step_id"] == "init"
    assert not hass.config_entries.flow._progress[result["flow_id"]].bridges

    result = await hass.config_entries.flow.async_configure(
        result["flow_id"],
        user_input={config_flow.CONF_HOST: "1.2.3.4", config_flow.CONF_PORT: 80},
    )
github Kane610 / deconz / tests / test_sensors.py View on Github external
async def test_consumption_sensor():
    """Verify that consumption sensor works."""
    sensor = create_sensor("0", FIXTURE_CONSUMPTION, None)

    assert sensor.BINARY is False
    assert sensor.ZHATYPE == ("ZHAConsumption",)

    assert sensor.state == 11.342
    assert sensor.consumption == 11342
    assert sensor.power == 123

    # DeconzSensor
    assert sensor.battery is None
    assert sensor.ep == 1
    assert sensor.lowbattery is None
    assert sensor.on is True
    assert sensor.reachable is True
    assert sensor.tampered is None
    assert sensor.secondary_temperature is None
github Kane610 / deconz / tests / test_sensors.py View on Github external
async def test_create_sensor_fails():
    """Verify failing behavior for create_sensor."""
    sensor_id = "0"
    sensor = {"type": "not supported", "name": "name"}
    result = create_sensor(sensor_id, sensor, None)

    assert result.BINARY is None
    assert not result.ZHATYPE
github Kane610 / deconz / tests / test_sensors.py View on Github external
async def test_create_sensor():
    """Verify that create-sensor can create all types."""
    assert len(SENSOR_CLASSES) == 19

    sensor_id = "0"

    for sensor_class in SENSOR_CLASSES:
        for sensor_type in sensor_class.ZHATYPE:
            sensor = {"type": sensor_type, "config": {}, "state": {}}
            result = create_sensor(sensor_id, sensor, None)

            assert result
github Kane610 / deconz / tests / test_sensors.py View on Github external
async def test_lightlevel_sensor():
    """Verify that light level sensor works."""
    sensor = create_sensor("0", FIXTURE_LIGHTLEVEL, None)

    assert sensor.BINARY is False
    assert sensor.ZHATYPE == ("ZHALightLevel", "CLIPLightLevel")

    assert sensor.state == 5
    assert sensor.dark is True
    assert sensor.daylight is False
    assert sensor.lightlevel == 6955
    assert sensor.lux == 5
    assert sensor.tholddark == 12000
    assert sensor.tholdoffset == 7000

    # DeconzSensor
    assert sensor.battery == 100
    assert sensor.ep == 2
    assert sensor.lowbattery is None
github Kane610 / deconz / tests / test_sensors.py View on Github external
async def test_genericstatus_sensor():
    """Verify that generic flag sensor works."""
    sensor = create_sensor("0", FIXTURE_GENERICSTATUS, None)

    assert sensor.BINARY is False
    assert sensor.ZHATYPE == ("CLIPGenericStatus",)

    assert sensor.state == 0
    assert sensor.status == 0

    # DeconzSensor
    assert sensor.battery is None
    assert sensor.ep is None
    assert sensor.lowbattery is None
    assert sensor.on is True
    assert sensor.reachable is True
    assert sensor.tampered is None
    assert sensor.secondary_temperature is None
github Kane610 / deconz / tests / test_sensors.py View on Github external
async def test_thermostat_sensor():
    """Verify that thermostat sensor works."""
    sensor = create_sensor("0", FIXTURE_THERMOSTAT, None)

    assert sensor.BINARY is False
    assert sensor.ZHATYPE == ("ZHAThermostat", "CLIPThermostat")

    assert sensor.state == 21.5
    assert sensor.heatsetpoint == 21.00
    assert sensor.locked is False
    assert sensor.mode == "auto"
    assert sensor.offset == 0
    assert sensor.state_on is False
    assert sensor.temperature == 21.5
    assert sensor.valve == 0

    # DeconzSensor
    assert sensor.battery == 100
    assert sensor.ep == 1
github Kane610 / deconz / tests / test_sensors.py View on Github external
async def test_temperature_sensor():
    """Verify that temperature sensor works."""
    sensor = create_sensor("0", FIXTURE_TEMPERATURE, None)

    assert sensor.BINARY is False
    assert sensor.ZHATYPE == ("ZHATemperature", "CLIPTemperature")

    assert sensor.state == 21.8
    assert sensor.temperature == 21.8

    # DeconzSensor
    assert sensor.battery == 100
    assert sensor.ep == 1
    assert sensor.lowbattery is None
    assert sensor.on is True
    assert sensor.reachable is True
    assert sensor.tampered is None
    assert sensor.secondary_temperature is None
github Kane610 / deconz / tests / test_sensors.py View on Github external
async def test_power_sensor():
    """Verify that power sensor works."""
    sensor = create_sensor("0", FIXTURE_POWER, None)

    assert sensor.BINARY is False
    assert sensor.ZHATYPE == ("ZHAPower",)

    assert sensor.state == 64
    assert sensor.current == 34
    assert sensor.power == 64
    assert sensor.voltage == 231

    # DeconzSensor
    assert sensor.battery is None
    assert sensor.ep == 1
    assert sensor.lowbattery is None
    assert sensor.on is True
    assert sensor.reachable is True
    assert sensor.tampered is None