1 """Sensor platform support for yeelight."""
11 from .const
import DATA_CONFIG_ENTRIES, DATA_DEVICE, DATA_UPDATED, DOMAIN
12 from .entity
import YeelightEntity
14 _LOGGER = logging.getLogger(__name__)
19 config_entry: ConfigEntry,
20 async_add_entities: AddEntitiesCallback,
22 """Set up Yeelight from a config entry."""
23 device = hass.data[DOMAIN][DATA_CONFIG_ENTRIES][config_entry.entry_id][DATA_DEVICE]
24 if device.is_nightlight_supported:
25 _LOGGER.debug(
"Adding nightlight mode sensor for %s", device.name)
30 """Representation of a Yeelight nightlight mode sensor."""
32 _attr_translation_key =
"nightlight"
35 """Handle entity which will be added."""
39 DATA_UPDATED.format(self.
_device_device.host),
47 """Return a unique ID."""
48 return f
"{self._unique_id}-nightlight_sensor"
52 """Return true if nightlight mode is on."""
53 return self.
_device_device.is_nightlight_enabled
None async_added_to_hass(self)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)