def __init__(self, fibaro_device): """Initialize the light.""" self._update_lock = asyncio.Lock() supports_color = ("color" in fibaro_device.properties or "colorComponents" in fibaro_device.properties or "RGB" in fibaro_device.type or "rgb" in fibaro_device.type or "color" in fibaro_device.baseType) and ( "setColor" in fibaro_device.actions or "setColorComponents" in fibaro_device.actions) supports_white_v = ("setW" in fibaro_device.actions or "RGBW" in fibaro_device.type or "rgbw" in fibaro_device.type) supports_dimming = "levelChange" in fibaro_device.interfaces if supports_color and supports_white_v: self._attr_supported_color_modes = {ColorMode.RGBW} self._attr_color_mode = ColorMode.RGBW elif supports_color: self._attr_supported_color_modes = {ColorMode.RGB} self._attr_color_mode = ColorMode.RGB elif supports_dimming: self._attr_supported_color_modes = {ColorMode.BRIGHTNESS} self._attr_color_mode = ColorMode.BRIGHTNESS else: self._attr_supported_color_modes = {ColorMode.ONOFF} self._attr_color_mode = ColorMode.ONOFF super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
def __init__(self, hass, device, endpoint): """Initialize the light.""" self._device = device self._endpoint = endpoint self._is_on = False a = self._device.get_attribute(endpoint, 6, 0) if a: self._is_on = a.get('value', False) ieee = device.ieee or device.addr # compatibility entity_id = 'zigate_{}_{}'.format(ieee, endpoint) self.entity_id = ENTITY_ID_FORMAT.format(entity_id) import zigate supported_features = set() supported_features.add(SUPPORT_TRANSITION) for action_type in device.available_actions(endpoint)[endpoint]: if action_type == zigate.ACTIONS_LEVEL: supported_features.add(SUPPORT_BRIGHTNESS) elif action_type == zigate.ACTIONS_COLOR: supported_features.add(SUPPORT_COLOR) elif action_type == zigate.ACTIONS_TEMPERATURE: supported_features.add(SUPPORT_COLOR_TEMP) elif action_type == zigate.ACTIONS_HUE: supported_features.add(SUPPORT_COLOR) self._supported_features = reduce(ior, supported_features) hass.bus.listen('zigate.attribute_updated', self._handle_event)
def __init__(self, fibaro_device): """Initialize the light.""" self._brightness = None self._color = (0, 0) self._last_brightness = 0 self._supported_flags = 0 self._update_lock = asyncio.Lock() self._white = 0 self._reset_color = False supports_color = ("color" in fibaro_device.properties or "colorComponents" in fibaro_device.properties or "RGB" in fibaro_device.type or "rgb" in fibaro_device.type or "color" in fibaro_device.baseType) and ( "setColor" in fibaro_device.actions or "setColorComponents" in fibaro_device.actions) supports_white_v = ("setW" in fibaro_device.actions or "RGBW" in fibaro_device.type or "rgbw" in fibaro_device.type) supports_dimming = ("levelChange" in fibaro_device.interfaces or supports_color or supports_white_v) # Configuration can override default capability detection if supports_dimming: self._supported_flags |= SUPPORT_BRIGHTNESS if supports_color: self._supported_flags |= SUPPORT_COLOR if supports_white_v: self._supported_flags |= SUPPORT_WHITE_VALUE super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
def __init__(self, fibaro_device): """Initialize the light.""" self._brightness = None self._color = (0, 0) self._last_brightness = 0 self._supported_flags = 0 self._update_lock = asyncio.Lock() self._white = 0 devconf = fibaro_device.device_config self._reset_color = devconf.get(CONF_RESET_COLOR, False) supports_color = 'color' in fibaro_device.properties and \ 'setColor' in fibaro_device.actions supports_dimming = 'levelChange' in fibaro_device.interfaces supports_white_v = 'setW' in fibaro_device.actions # Configuration can overrride default capability detection if devconf.get(CONF_DIMMING, supports_dimming): self._supported_flags |= SUPPORT_BRIGHTNESS if devconf.get(CONF_COLOR, supports_color): self._supported_flags |= SUPPORT_COLOR if devconf.get(CONF_WHITE_VALUE, supports_white_v): self._supported_flags |= SUPPORT_WHITE_VALUE super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
def __init__(self, fibaro_device): """Initialize the light.""" self._brightness = None self._color = (0, 0) self._last_brightness = 0 self._supported_flags = 0 self._update_lock = asyncio.Lock() self._white = 0 devconf = fibaro_device.device_config self._reset_color = devconf.get(CONF_RESET_COLOR, False) supports_color = 'color' in fibaro_device.properties and \ 'setColor' in fibaro_device.actions supports_dimming = 'levelChange' in fibaro_device.interfaces supports_white_v = 'setW' in fibaro_device.actions # Configuration can overrride default capability detection if devconf.get(CONF_DIMMING, supports_dimming): self._supported_flags |= SUPPORT_BRIGHTNESS if devconf.get(CONF_COLOR, supports_color): self._supported_flags |= SUPPORT_COLOR if devconf.get(CONF_WHITE_VALUE, supports_white_v): self._supported_flags |= SUPPORT_WHITE_VALUE super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
def __init__(self, vera_device, controller): """Initialize the light.""" self._state = False self._color = None self._brightness = None VeraDevice.__init__(self, vera_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
def __init__(self, vera_device, controller): """Initialize the light.""" self._state = False self._color = None self._brightness = None VeraDevice.__init__(self, vera_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
def __init__(self, vera_device: veraApi.VeraDimmer, controller_data: ControllerData) -> None: """Initialize the light.""" self._state = False self._color: tuple[float, float] | None = None self._brightness = None VeraDevice.__init__(self, vera_device, controller_data) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
def __init__(self, ip, dev_type): """Initialize the MagicHomeLight.""" self.ctrl = MagicHomeApi(ip, dev_type) self._dev_type = dev_type self._tick = 0 self.entity_id = ENTITY_ID_FORMAT.format( ("magichome_" + ip.replace(".", "_")).lower()) self._ecount = 0 stat = self.ctrl.get_status() _LOGGER.info("magic_home stat: %s" % (stat)) if stat == -1: self._available = False else: if self.check_recv(stat[0], stat[1]): self._state = stat rgb = (self._state[6], self._state[7], self._state[8]) _LOGGER.info("magic_home_rgb: %s", str(rgb)) max_color = max(rgb) self._brightness = max_color hs_rgb = rgb if max_color != 0: hs_rgb = (rgb[0] * 255 / max_color, rgb[1] * 255 / max_color, rgb[2] * 255 / max_color) self._hs = color_util.color_RGB_to_hs(*hs_rgb) self._available = True self._white_value = stat[5] * 255 / 100 if stat[2] == 0x23: self._ison = True else: self._ison = False if stat[3] == 0 and stat[4] == 0x61: self._effect = "0" else: if self._dev_type == 5: self._effect = str(stat[3] * 256 + stat[4] - 99) else: # self._effect = list(PATTERN_DICT.keys())[list(PATTERN_DICT.values()).index(stat[4])] self._effect = "0" else: self._hs = None self._ison = False self._effect = None self._brightness = None eff_list = [] if self._dev_type == 5: for i in range(301): eff_list.append(str(i)) else: for i in PATTERN_DICT: eff_list.append(i) self._effect_list = eff_list
def __init__(self, homee_node, homee_attribute, cube): """Initialize the switch.""" from pyhomee import const self._state = homee_attribute.value self._color = None self.brightness_attr = get_attr_by_type(homee_node, const.BRIGHTNESS) if self.brightness_attr: self._brightness = self.brightness_attr.value else: self._brightness = None self.attribute_id = homee_attribute.id HomeeDevice.__init__(self, homee_node, homee_attribute, cube) self.entity_id = ENTITY_ID_FORMAT.format(self.homee_id) self.update_state(homee_attribute)
def __init__(self, fibaro_device, controller): """Initialize the light.""" self._supported_flags = 0 self._last_brightness = 0 self._color = (0, 0) self._brightness = None self._white = 0 self._update_lock = asyncio.Lock() if 'levelChange' in fibaro_device.interfaces: self._supported_flags |= SUPPORT_BRIGHTNESS if 'color' in fibaro_device.properties: self._supported_flags |= SUPPORT_COLOR if 'setW' in fibaro_device.actions: self._supported_flags |= SUPPORT_WHITE_VALUE super().__init__(fibaro_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
def __init__(self, fibaro_device, controller): """Initialize the light.""" self._supported_flags = 0 self._last_brightness = 0 self._color = (0, 0) self._brightness = None self._white = 0 self._update_lock = asyncio.Lock() if 'levelChange' in fibaro_device.interfaces: self._supported_flags |= SUPPORT_BRIGHTNESS if 'color' in fibaro_device.properties and \ 'setColor' in fibaro_device.actions: self._supported_flags |= SUPPORT_COLOR if 'setW' in fibaro_device.actions: self._supported_flags |= SUPPORT_WHITE_VALUE super().__init__(fibaro_device, controller) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
def __init__(self, device, endpoint): """Initialize the light.""" self._device = device self._endpoint = endpoint entity_id = 'zigate_{}_{}'.format(device.addr, endpoint) self.entity_id = ENTITY_ID_FORMAT.format(entity_id) import zigate supported_features = set() supported_features.add(SUPPORT_TRANSITION) for action_type in device.available_actions(endpoint)[endpoint]: if action_type == zigate.ACTIONS_LEVEL: supported_features.add(SUPPORT_BRIGHTNESS) elif action_type == zigate.ACTIONS_COLOR: supported_features.add(SUPPORT_COLOR) elif action_type == zigate.ACTIONS_TEMPERATURE: supported_features.add(SUPPORT_COLOR_TEMP) elif action_type == zigate.ACTIONS_HUE: supported_features.add(SUPPORT_COLOR) self._supported_features = reduce(ior, supported_features)
def __init__(self, dev, idx, val, param): """Initialize the LifeSmartLight.""" super().__init__(dev, idx, val, param) self.entity_id = ENTITY_ID_FORMAT.format( (dev['devtype'] + "_" + dev['me'] + "_" + idx).lower()) if val['type'] % 2 == 1: self._state = True else: self._state = False value = val['val'] if value == 0: self._hs = None else: rgbhexstr = "%x" % value rgbhexstr = rgbhexstr.zfill(8) rgbhex = bytes.fromhex(rgbhexstr) rgba = struct.unpack("BBBB", rgbhex) rgb = rgba[1:] self._hs = color_util.color_RGB_to_hs(*rgb) _LOGGER.info("hs_rgb: %s", str(self._hs))
def __init__(self, ip, dev_type): """Initialize the MagicHomeLight.""" self.ctrl = MagicHomeApi(ip, dev_type) self._tick = 0 self.entity_id = ENTITY_ID_FORMAT.format( ("magichome_" + ip.replace(".", "_")).lower()) self._transition = 1 stat = self.ctrl.get_status() if stat[1] == 161: self._state = stat rgb = (self._state[6], self._state[7], self._state[8]) _LOGGER.info("magic_home_rgb: %s", str(rgb)) max_color = max(rgb) self._brightness = max_color hs_rgb = (rgb[0] * 255 / max_color, rgb[2] * 255 / max_color, rgb[1] * 255 / max_color) self._hs = color_util.color_RGB_to_hs(*hs_rgb) self._available = True self._white_value = stat[5] if stat[2] == 0x23: self._ison = True else: self._ison = False if stat[3] == 0 and stat[4] == 0x61: self._effect = "0" else: self._effect = str(stat[3] * 256 + stat[4] - 99) else: self._hs = None self._ison = False self._effect = None self._brightness = None eff_list = [] for i in range(300): eff_list.append(str(i)) self._effect_list = eff_list
def __init__(self, tuya): """Init Tuya light device.""" super().__init__(tuya) self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id())
def __init__(self, tuya, platform): """Init Tuya light device.""" super().__init__(tuya, platform) self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id()) self._min_kelvin = tuya.max_color_temp() self._max_kelvin = tuya.min_color_temp()
def orgb_entity_id(instance): """Return the ORGB devices entity ID.""" return ENTITY_ID_FORMAT.format(orgb_object_id(instance))
def __init__(self, light): """Initialize our light.""" super().__init__() self._light = light self.entity_id = ENTITY_ID_FORMAT.format(light.id)
def __init__(self, tuya): """Init Tuya light device.""" super().__init__(tuya) self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id()) self.tuya = tuya
def __init__(self, hass, homee_node, cube): """Initialize the switch.""" HomeeDevice.__init__(self, hass, homee_node, cube) self.entity_id = ENTITY_ID_FORMAT.format(self.homee_id)