Exemplo n.º 1
0
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up the light from config."""
    from mirobo import Ceil, DeviceException
    if PLATFORM not in hass.data:
        hass.data[PLATFORM] = {}

    host = config.get(CONF_HOST)
    name = config.get(CONF_NAME)
    token = config.get(CONF_TOKEN)

    _LOGGER.info("Initializing with host %s (token %s...)", host, token[:5])

    try:
        light = Ceil(host, token)
        device_info = light.info()
        _LOGGER.info("%s %s %s initialized",
                     device_info.raw['model'],
                     device_info.raw['fw_ver'],
                     device_info.raw['hw_ver'])

        philips_light = XiaomiPhilipsLight(name, light, device_info)
        hass.data[PLATFORM][host] = philips_light
    except DeviceException:
        raise PlatformNotReady

    async_add_devices([philips_light], update_before_add=True)
Exemplo n.º 2
0
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up the light from config."""
    from mirobo import Ceil, DeviceException
    if PLATFORM not in hass.data:
        hass.data[PLATFORM] = {}

    host = config.get(CONF_HOST)
    name = config.get(CONF_NAME)
    token = config.get(CONF_TOKEN)

    _LOGGER.info("Initializing with host %s (token %s...)", host, token[:5])

    try:
        light = Ceil(host, token)
        device_info = light.info()
        _LOGGER.info("%s %s %s initialized",
                     device_info.raw['model'],
                     device_info.raw['fw_ver'],
                     device_info.raw['hw_ver'])

        philips_light = XiaomiPhilipsLight(name, light, device_info)
        hass.data[PLATFORM][host] = philips_light
    except DeviceException:
        raise PlatformNotReady

    async_add_devices([philips_light], update_before_add=True)
Exemplo n.º 3
0
    def light(self):
        """Property accessor for light object."""
        if not self._light:
            from mirobo import Ceil
            _LOGGER.info("Initializing light with host %s", self.host)
            self._light = Ceil(self.host, self.token)

        return self._light
Exemplo n.º 4
0
def status(dev: mirobo.Ceil):
    """Returns the state information."""
    res = dev.status()
    if not res:
        return  # bail out

    click.echo(click.style("Power: %s" % res.power, bold=True))
    click.echo("Brightness: %s" % res.bright)
    click.echo("CCT: %s" % res.cct)
    click.echo("Scene Number: %s" % res.snm)
    click.echo("dv: %s" % res.dv)
    click.echo("Smart Midnight Light: %s" % res.bl)
    click.echo("Auto CCT: %s" % res.ac)
Exemplo n.º 5
0
def status(dev: mirobo.Ceil):
    """Returns the state information."""
    res = dev.status()
    if not res:
        return  # bail out

    click.echo(click.style("Power: %s" % res.power, bold=True))
    click.echo("Brightness: %s" % res.brightness)
    click.echo("Color temperature: %s" % res.color_temperature)
    click.echo("Scene: %s" % res.scene)
    click.echo("dv: %s" % res.dv)
    click.echo("Smart Night Light: %s" % res.smart_night_light)
    click.echo("Auto CCT: %s" % res.automatic_color_temperature)
Exemplo n.º 6
0
def off(dev: mirobo.Ceil):
    """Power off."""
    click.echo("Power off: %s" % dev.off())
Exemplo n.º 7
0
def automatic_color_temperature_off(dev: mirobo.Ceil):
    """Auto CCT on."""
    click.echo("Auto CCT Off: %s" % dev.automatic_color_temperature_off())
Exemplo n.º 8
0
def smart_night_light_off(dev: mirobo.Ceil):
    """Smart Night Light off."""
    click.echo("Smart Night Light Off: %s" % dev.smart_night_light_off())
Exemplo n.º 9
0
def smart_night_light_on(dev: mirobo.Ceil):
    """Smart Night Light on."""
    click.echo("Smart Night Light On: %s" % dev.smart_night_light_on())
Exemplo n.º 10
0
def set_scene(dev: mirobo.Ceil, scene):
    """Set scene number."""
    click.echo("Eyecare Scene: %s" % dev.set_scene(scene))
Exemplo n.º 11
0
def delay_off(dev: mirobo.Ceil, seconds):
    """Set delay off in seconds."""
    click.echo("Delay off: %s" % dev.delay_off(seconds))
Exemplo n.º 12
0
def set_color_temperature(dev: mirobo.Ceil, level):
    """Set CCT level."""
    click.echo("Correlated color temperatur level: %s" %
               dev.set_color_temperature(level))
Exemplo n.º 13
0
def set_brightness(dev: mirobo.Ceil, level):
    """Set brightness level."""
    click.echo("Brightness: %s" % dev.set_brightness(level))
Exemplo n.º 14
0
def set_cct(dev: mirobo.Ceil, level):
    """Set CCT level."""
    click.echo("CCT level: %s" % dev.set_cct(level))
Exemplo n.º 15
0
def on(dev: mirobo.Ceil):
    """Power on."""
    click.echo("Power on: %s" % dev.on())
Exemplo n.º 16
0
def sml_on(dev: mirobo.Ceil):
    """Smart Midnight Light on."""
    click.echo("Smart Midnight Light On: %s" % dev.bl_on())
Exemplo n.º 17
0
def acct_off(dev: mirobo.Ceil):
    """Auto CCT on."""
    click.echo("Auto CCT Off: %s" % dev.ac_off())
Exemplo n.º 18
0
def acct_on(dev: mirobo.Ceil):
    """Auto CCT on."""
    click.echo("Auto CCT On: %s" % dev.ac_on())
Exemplo n.º 19
0
def sml_off(dev: mirobo.Ceil):
    """Smart Midnight Light off."""
    click.echo("Smart Midnight Light Off: %s" % dev.bl_off())