How to use the pytradfri.device.Device function in pytradfri

To help you get started, we’ve selected a few pytradfri 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 ggravlingen / pytradfri / tests / test_light.py View on Github external
def light(raw):
    return Device(raw).light_control.lights[0]
github ggravlingen / pytradfri / tests / test_device.py View on Github external
def test_binary_division():
    dev_ws = Device(LIGHT_WS).light_control.lights[0]
    dev_color = Device(LIGHT_CWS).light_control.lights[0]

    assert dev_ws.dimmer == 254
    assert dev_ws.color_temp == 400
    assert dev_color.hex_color == 'f1e0b5'
    assert dev_color.xy_color == (30015, 26870)
github ggravlingen / pytradfri / tests / test_device.py View on Github external
from pytradfri.device import Device
from devices import (
    LIGHT_W, LIGHT_WS, LIGHT_CWS, LIGHT_PHILIPS, REMOTE_CONTROL,
    MOTION_SENSOR, OUTLET, BLIND)


@pytest.fixture
def device():
    return Device(LIGHT_WS)


input_devices = (
    ("comment", "device"),
    [
        ("Remote control", Device(REMOTE_CONTROL)),
        ("Motion sensor", Device(MOTION_SENSOR)),
    ]
)

output_devices = (
    ("comment", "device"),
    [
        ("White fixed color bulb", Device(LIGHT_W)),
        ("White spectrum bulb", Device(LIGHT_WS)),
        ("Full color bulb", Device(LIGHT_CWS)),
        ("Philips Hue bulb", Device(LIGHT_PHILIPS)),
    ]
)

wall_plugs = (
    ("comment", "device"),
    [
github ggravlingen / pytradfri / tests / test_device.py View on Github external
def test_socket_state_on(device):
    if device.has_socket_control:
        socket = Device(device.raw.copy()).socket_control.socket[0]
        socket.raw[ATTR_DEVICE_STATE] = 1
        assert socket.state is True
github ggravlingen / pytradfri / tests / test_device.py View on Github external
def test_light_state_mangled(device):
    light = Device(device.raw.copy()).light_control.lights[0]
    light.raw[ATTR_DEVICE_STATE] = "RandomString"
    assert light.state is False
github ggravlingen / pytradfri / tests / test_device.py View on Github external
def device():
    return Device(LIGHT_WS)


input_devices = (
    ("comment", "device"),
    [
        ("Remote control", Device(REMOTE_CONTROL)),
        ("Motion sensor", Device(MOTION_SENSOR)),
    ]
)

output_devices = (
    ("comment", "device"),
    [
        ("White fixed color bulb", Device(LIGHT_W)),
        ("White spectrum bulb", Device(LIGHT_WS)),
        ("Full color bulb", Device(LIGHT_CWS)),
        ("Philips Hue bulb", Device(LIGHT_PHILIPS)),
    ]
)

wall_plugs = (
    ("comment", "device"),
    [
        ("Wall plug", Device(OUTLET))
    ]
)

roller_blinds = (
    ("comment", "device"),
    [
github ggravlingen / pytradfri / tests / test_device.py View on Github external
def test_has_light_control_false(device):
    dev = Device(device.raw.copy())
    dev.raw[ATTR_LIGHT_CONTROL] = {}
    assert dev.has_light_control is False
github ggravlingen / pytradfri / pytradfri / gateway.py View on Github external
def process_result(result):
            return Device(result)