How to use the pytradfri.const.ATTR_LIGHT_DIMMER 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_device.py View on Github external
ATTR_TRANSITION_TIME: 2
            },
        ],

        [
            "set_dimmer", "valid", {
                'dimmer': 200,
            }, {
                ATTR_LIGHT_DIMMER: 200,
            },
        ],
        [
            "set_dimmer", "none", {
                'dimmer': None,
            }, {
                ATTR_LIGHT_DIMMER: None,
            },
        ],
        [
            "set_dimmer", "with_transitiontime", {
                'dimmer': 200,
                'transition_time': 2
            }, {
                ATTR_LIGHT_DIMMER: 200,
                ATTR_TRANSITION_TIME: 2
            },
        ],

        [
            "set_state", "true", {
                'state': True,
            }, {
github ggravlingen / pytradfri / tests / test_group.py View on Github external
assert cmd.data == {'5712': 100, '5706': 'ebb63e'}

    cmd = Group('anygateway', GROUP) \
        .set_xy_color(200, 45000)
    assert cmd.data == {'5709': 200, '5710': 45000}

    cmd = Group('anygateway', GROUP) \
        .set_color_temp(300)
    assert cmd.data == {ATTR_LIGHT_MIREDS: 300}

    cmd = Group('anygateway', GROUP) \
        .set_hsb(300, 200, 100)
    assert cmd.data == {
        ATTR_LIGHT_COLOR_HUE: 300,
        ATTR_LIGHT_COLOR_SATURATION: 200,
        ATTR_LIGHT_DIMMER: 100,
    }
github ggravlingen / pytradfri / pytradfri / device.py View on Github external
def dimmer(self):
        if self.supported_features & SUPPORT_BRIGHTNESS:
            return self.raw.get(ATTR_LIGHT_DIMMER)
github ggravlingen / pytradfri / pytradfri / group.py View on Github external
def dimmer(self):
        """Dimmer value of the group."""
        return self.raw.get(ATTR_LIGHT_DIMMER)
github ggravlingen / pytradfri / pytradfri / color.py View on Github external
def supported_features(data):
    SUPPORTED_COLOR_FEATURES = 0

    if ATTR_LIGHT_DIMMER in data:
        SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
            + SUPPORT_BRIGHTNESS

    if ATTR_LIGHT_COLOR_HEX in data:
        SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
            + SUPPORT_HEX_COLOR

    if ATTR_LIGHT_MIREDS in data:
        SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
            + SUPPORT_COLOR_TEMP

    if X in data and Y in data:
        SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
            + SUPPORT_XY_COLOR

    if ATTR_LIGHT_MIREDS not in data and X in data and Y in data and \
github ggravlingen / pytradfri / pytradfri / group.py View on Github external
def set_hsb(self, hue, saturation, brightness=None, *, index=0,
                transition_time=None):
        """Set HSB color settings of the light."""
        self._value_validate(hue, RANGE_HUE, "Hue")
        self._value_validate(saturation, RANGE_SATURATION, "Saturation")

        values = {
            ATTR_LIGHT_COLOR_SATURATION: saturation,
            ATTR_LIGHT_COLOR_HUE: hue
        }

        if brightness is not None:
            values[ATTR_LIGHT_DIMMER] = brightness
            self._value_validate(brightness, RANGE_BRIGHTNESS, "Brightness")

        if transition_time is not None:
            values[ATTR_TRANSITION_TIME] = transition_time

        return self.set_values(values)
github ggravlingen / pytradfri / pytradfri / smart_task.py View on Github external
def set_transition_time(self, transition_time):
        """Set time (mins) for light transition."""
        command = {
            ATTR_START_ACTION: {
                    ATTR_DEVICE_STATE: self.state,
                    ROOT_START_ACTION: [{
                        ATTR_ID: self.raw[ATTR_ID],
                        ATTR_LIGHT_DIMMER: self.raw[ATTR_LIGHT_DIMMER],
                        ATTR_TRANSITION_TIME: transition_time * 10 * 60
                    }, self.devices_dict]
                }
            }
        return self.set_values(command)
github ggravlingen / pytradfri / pytradfri / smart_task.py View on Github external
def dimmer(self):
        """Return dimmer level."""
        return self.raw.get(ATTR_LIGHT_DIMMER)
github ggravlingen / pytradfri / pytradfri / device.py View on Github external
def set_dimmer(self, dimmer, *, index=0, transition_time=None):
        """Set dimmer value of a light.
        transition_time: Integer representing tenth of a second (default None)
        """
        self._value_validate(dimmer, RANGE_BRIGHTNESS, "Dimmer")

        values = {
            ATTR_LIGHT_DIMMER: dimmer
        }

        if transition_time is not None:
            values[ATTR_TRANSITION_TIME] = transition_time

        return self.set_values(values, index=index)