How to use the pytradfri.const.ATTR_LIGHT_COLOR_HUE 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_group.py View on Github external
cmd = Group('anygateway', GROUP) \
        .set_predefined_color('Candlelight', 100)
    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 / tests / test_device.py View on Github external
"set_hsb", "setting_hue_none", {
                'hue': None,
                'saturation': 200
            }, {
                ATTR_LIGHT_COLOR_HUE: None,
                ATTR_LIGHT_COLOR_SATURATION: 200
            },
        ],
        [
            "set_hsb", "with_transitiontime", {
                'hue': 300,
                'saturation': 200,
                'brightness': 100,
                'transition_time': 2
            }, {
                ATTR_LIGHT_COLOR_HUE: 300,
                ATTR_LIGHT_COLOR_SATURATION: 200,
                ATTR_LIGHT_DIMMER: 100,
                ATTR_TRANSITION_TIME: 2
            },
        ],
        [
            "set_hsb", "with_faulty_transitiontime", {
                'hue': 300,
                'saturation': 200,
                'transition_time': -2
            }, {
                ATTR_LIGHT_COLOR_HUE: 300,
                ATTR_LIGHT_COLOR_SATURATION: 200,
                ATTR_TRANSITION_TIME: -2
            },
        ],
github ggravlingen / pytradfri / pytradfri / color.py View on Github external
+ 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 \
            ATTR_LIGHT_COLOR_SATURATION in data and ATTR_LIGHT_COLOR_HUE\
            in data:
        SUPPORTED_COLOR_FEATURES = SUPPORTED_COLOR_FEATURES\
            + SUPPORT_RGB_COLOR

    return SUPPORTED_COLOR_FEATURES
github ggravlingen / pytradfri / pytradfri / device.py View on Github external
def hsb_xy_color(self):
        return (self.raw.get(ATTR_LIGHT_COLOR_HUE),
                self.raw.get(ATTR_LIGHT_COLOR_SATURATION),
                self.raw.get(ATTR_LIGHT_DIMMER),
                self.raw.get(ATTR_LIGHT_COLOR_X),
                self.raw.get(ATTR_LIGHT_COLOR_Y))
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 / device.py View on Github external
self.can_set_dimmer = None
        self.can_set_temp = None
        self.can_set_xy = None
        self.can_set_color = None
        self.can_combine_commands = None

        if ATTR_LIGHT_DIMMER in self.raw[0]:
            self.can_set_dimmer = True

        if ATTR_LIGHT_MIREDS in self.raw[0]:
            self.can_set_temp = True

        if ATTR_LIGHT_COLOR_X in self.raw[0]:
            self.can_set_xy = True

        if ATTR_LIGHT_COLOR_HUE in self.raw[0]:
            self.can_set_color = True

        # Currently uncertain which bulbs are capable of setting
        # multiple values simultaneously. As of gateway firmware
        # 1.3.14 1st party bulbs do not seem to support this properly,
        # but (at least some) hue bulbs do.
        if 'Philips' in self._device.device_info.manufacturer:
            self.can_combine_commands = True

        self.min_mireds = RANGE_MIREDS[0]
        self.max_mireds = RANGE_MIREDS[1]

        self.min_hue = RANGE_HUE[0]
        self.max_hue = RANGE_HUE[1]

        self.min_saturation = RANGE_SATURATION[0]