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)
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
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)
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)
def off(dev: mirobo.Ceil): """Power off.""" click.echo("Power off: %s" % dev.off())
def automatic_color_temperature_off(dev: mirobo.Ceil): """Auto CCT on.""" click.echo("Auto CCT Off: %s" % dev.automatic_color_temperature_off())
def smart_night_light_off(dev: mirobo.Ceil): """Smart Night Light off.""" click.echo("Smart Night Light Off: %s" % dev.smart_night_light_off())
def smart_night_light_on(dev: mirobo.Ceil): """Smart Night Light on.""" click.echo("Smart Night Light On: %s" % dev.smart_night_light_on())
def set_scene(dev: mirobo.Ceil, scene): """Set scene number.""" click.echo("Eyecare Scene: %s" % dev.set_scene(scene))
def delay_off(dev: mirobo.Ceil, seconds): """Set delay off in seconds.""" click.echo("Delay off: %s" % dev.delay_off(seconds))
def set_color_temperature(dev: mirobo.Ceil, level): """Set CCT level.""" click.echo("Correlated color temperatur level: %s" % dev.set_color_temperature(level))
def set_brightness(dev: mirobo.Ceil, level): """Set brightness level.""" click.echo("Brightness: %s" % dev.set_brightness(level))
def set_cct(dev: mirobo.Ceil, level): """Set CCT level.""" click.echo("CCT level: %s" % dev.set_cct(level))
def on(dev: mirobo.Ceil): """Power on.""" click.echo("Power on: %s" % dev.on())
def sml_on(dev: mirobo.Ceil): """Smart Midnight Light on.""" click.echo("Smart Midnight Light On: %s" % dev.bl_on())
def acct_off(dev: mirobo.Ceil): """Auto CCT on.""" click.echo("Auto CCT Off: %s" % dev.ac_off())
def acct_on(dev: mirobo.Ceil): """Auto CCT on.""" click.echo("Auto CCT On: %s" % dev.ac_on())
def sml_off(dev: mirobo.Ceil): """Smart Midnight Light off.""" click.echo("Smart Midnight Light Off: %s" % dev.bl_off())