File: light.py

package info (click to toggle)
python-miio 0.5.12-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,888 kB
  • sloc: python: 23,425; makefile: 9
file content (30 lines) | stat: -rw-r--r-- 843 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Xiaomi Zigbee lights."""

import click

from ...click_common import command
from .subdevice import SubDevice


class LightBulb(SubDevice):
    """Base class for subdevice light bulbs."""

    @command()
    def on(self):
        """Turn bulb on."""
        return self.send_arg("set_power", ["on"]).pop()

    @command()
    def off(self):
        """Turn bulb off."""
        return self.send_arg("set_power", ["off"]).pop()

    @command(click.argument("ctt", type=int))
    def set_color_temp(self, ctt):
        """Set the color temperature of the bulb ctt_min-ctt_max."""
        return self.send_arg("set_ct", [ctt]).pop()

    @command(click.argument("brightness", type=int))
    def set_brightness(self, brightness):
        """Set the brightness of the bulb 1-100."""
        return self.send_arg("set_bright", [brightness]).pop()