def async_update(self): """Retrieve latest state.""" result = yield from zha.safe_read(self._endpoint.on_off, ['on_off']) self._state = result.get('on_off', self._state) if self._supported_features & light.SUPPORT_BRIGHTNESS: result = yield from zha.safe_read(self._endpoint.level, ['current_level']) self._brightness = result.get('current_level', self._brightness) if self._supported_features & light.SUPPORT_COLOR_TEMP: result = yield from zha.safe_read(self._endpoint.light_color, ['color_temperature']) self._color_temp = result.get('color_temperature', self._color_temp) if self._supported_features & light.SUPPORT_XY_COLOR: result = yield from zha.safe_read(self._endpoint.light_color, ['current_x', 'current_y']) if 'current_x' in result and 'current_y' in result: self._xy_color = (result['current_x'], result['current_y'])
def async_update(self): """Retrieve latest state.""" result = yield from zha.safe_read(self._endpoint.on_off, ['on_off']) self._state = result.get('on_off', self._state) if self._supported_features & light.SUPPORT_BRIGHTNESS: result = yield from zha.safe_read(self._endpoint.level, ['current_level']) self._brightness = result.get('current_level', self._brightness) if self._supported_features & light.SUPPORT_COLOR_TEMP: result = yield from zha.safe_read(self._endpoint.light_color, ['color_temperature']) self._color_temp = result.get('color_temperature', self._color_temp) if self._supported_features & light.SUPPORT_XY_COLOR: result = yield from zha.safe_read(self._endpoint.light_color, ['current_x', 'current_y']) if 'current_x' in result and 'current_y' in result: self._xy_color = (result['current_x'], result['current_y'])
def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the Zigbee Home Automation lights.""" discovery_info = zha.get_discovery_info(hass, discovery_info) if discovery_info is None: return endpoint = discovery_info['endpoint'] if hasattr(endpoint, 'light_color'): caps = yield from zha.safe_read(endpoint.light_color, ['color_capabilities']) discovery_info['color_capabilities'] = caps.get('color_capabilities') if discovery_info['color_capabilities'] is None: # ZCL Version 4 devices don't support the color_capabilities # attribute. In this version XY support is mandatory, but we need # to probe to determine if the device supports color temperature. discovery_info['color_capabilities'] = CAPABILITIES_COLOR_XY result = yield from zha.safe_read(endpoint.light_color, ['color_temperature']) if result.get('color_temperature') is not UNSUPPORTED_ATTRIBUTE: discovery_info['color_capabilities'] |= CAPABILITIES_COLOR_TEMP async_add_devices([Light(**discovery_info)], update_before_add=True)
def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the Zigbee Home Automation lights.""" discovery_info = zha.get_discovery_info(hass, discovery_info) if discovery_info is None: return endpoint = discovery_info['endpoint'] if hasattr(endpoint, 'light_color'): caps = yield from zha.safe_read( endpoint.light_color, ['color_capabilities']) discovery_info['color_capabilities'] = caps.get('color_capabilities') if discovery_info['color_capabilities'] is None: # ZCL Version 4 devices don't support the color_capabilities # attribute. In this version XY support is mandatory, but we need # to probe to determine if the device supports color temperature. discovery_info['color_capabilities'] = CAPABILITIES_COLOR_XY result = yield from zha.safe_read( endpoint.light_color, ['color_temperature']) if result.get('color_temperature') is not UNSUPPORTED_ATTRIBUTE: discovery_info['color_capabilities'] |= CAPABILITIES_COLOR_TEMP async_add_devices([Light(**discovery_info)], update_before_add=True)
def async_update(self): """Retrieve latest state.""" _LOGGER.debug("%s async_update", self.entity_id) result = yield from zha.safe_read( self._endpoint.power, ['battery_size', 'battery_quantity', 'battery_voltage']) self._device_state_attributes['battery_size'] = \ self.battery_sizes.get( result.get('battery_size', 255), 'Unknown' ) self._device_state_attributes['battery_quantity'] = result.get( 'battery_quantity', 'Unknown') self._state = result.get('battery_voltage', self._state)
def async_update(self): """Retrieve latest state.""" result = yield from zha.safe_read(self._endpoint.fan, ['fan_mode']) new_value = result.get('fan_mode', None) self._state = VALUE_TO_SPEED.get(new_value, None)
def async_update(self): """Retrieve latest state.""" result = yield from zha.safe_read(self._endpoint.fan, ['fan_mode']) new_value = result.get('fan_mode', None) self._state = VALUE_TO_SPEED.get(new_value, None)