How to use the yeelight.enums.PowerMode.LAST function in yeelight

To help you get started, we’ve selected a few yeelight 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 skorokithakis / python-yeelight / yeelight / tests.py View on Github external
def test_set_power_mode3(self):
        self.bulb.set_power_mode(enums.PowerMode.LAST)
        self.assertEqual(self.socket.sent["method"], "set_power")
        self.assertEqual(self.socket.sent["params"], ["on", "smooth", 300])
github davidramiro / fluxee / yeelight / main.py View on Github external
"set_hsv": ["hue", "sat"],
                "set_bright": ["bright"],
                "set_power": ["power"],
            }
            # Handle toggling separately, as it depends on a previous power state.
            if method == "toggle":
                self._last_properties["power"] = "on" if self._last_properties["power"] == "off" else "off"
            elif method in action_property_map:
                set_prop = action_property_map[method]
                update_props = {set_prop[prop]: params[prop] for prop in range(len(set_prop))}
                _LOGGER.debug("Music mode cache update: %s", update_props)
                self._last_properties.update(update_props)
        # Add the effect parameters.
        params += [effect, duration]
        # Add power_mode parameter.
        if method == "set_power" and params[0] == "on" and power_mode.value != PowerMode.LAST:
            params += [power_mode.value]

    result = self.send_command(method, params).get("result", [])
    if result:
        return result[0]
github skorokithakis / python-yeelight / yeelight / main.py View on Github external
def __init__(
        self, ip, port=55443, effect="smooth", duration=300, auto_on=False, power_mode=PowerMode.LAST, model=None
    ):
        """
        The main controller class of a physical YeeLight bulb.

        :param str ip:       The IP of the bulb.
        :param int port:     The port to connect to on the bulb.
        :param str effect:   The type of effect. Can be "smooth" or "sudden".
        :param int duration: The duration of the effect, in milliseconds. The
                             minimum is 30. This is ignored for sudden effects.
        :param bool auto_on: Whether to call :py:meth:`ensure_on()
                             ` to turn the bulb on
                             automatically before each operation, if it is off.
                             This renews the properties of the bulb before each
                             message, costing you one extra message per command.
                             Turn this off and do your own checking with
                             :py:meth:`get_properties()
github skorokithakis / python-yeelight / yeelight / main.py View on Github external
"set_hsv": ["hue", "sat"],
                "set_bright": ["bright"],
                "set_power": ["power"],
            }
            # Handle toggling separately, as it depends on a previous power state.
            if method == "toggle":
                self._last_properties["power"] = "on" if self._last_properties["power"] == "off" else "off"
            elif method in action_property_map:
                set_prop = action_property_map[method]
                update_props = {set_prop[prop]: params[prop] for prop in range(len(set_prop))}
                _LOGGER.debug("Music mode cache update: %s", update_props)
                self._last_properties.update(update_props)
        # Add the effect parameters.
        params += [effect, duration]
        # Add power_mode parameter.
        if method == "set_power" and params[0] == "on" and power_mode.value != PowerMode.LAST:
            params += [power_mode.value]

    result = self.send_command(method, params).get("result", [])
    if result:
        return result[0]
github davidramiro / fluxee / yeelight / main.py View on Github external
def __init__(
        self, ip, port=55443, effect="smooth", duration=300, auto_on=False, power_mode=PowerMode.LAST, model=None
    ):
        """
        The main controller class of a physical YeeLight bulb.

        :param str ip:       The IP of the bulb.
        :param int port:     The port to connect to on the bulb.
        :param str effect:   The type of effect. Can be "smooth" or "sudden".
        :param int duration: The duration of the effect, in milliseconds. The
                             minimum is 30. This is ignored for sudden effects.
        :param bool auto_on: Whether to call :py:meth:`ensure_on()
                             ` to turn the bulb on
                             automatically before each operation, if it is off.
                             This renews the properties of the bulb before each
                             message, costing you one extra message per command.
                             Turn this off and do your own checking with
                             :py:meth:`get_properties()