1 """Support for Duotecno lights."""
5 from duotecno.controller
import PyDuotecno
6 from duotecno.unit
import DimUnit
13 from .const
import DOMAIN
14 from .entity
import DuotecnoEntity, api_call
20 async_add_entities: AddEntitiesCallback,
22 """Set up Duotecno light based on config_entry."""
23 cntrl: PyDuotecno = hass.data[DOMAIN][entry.entry_id]
28 """Representation of a light."""
31 _attr_color_mode = ColorMode.BRIGHTNESS
32 _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
36 """Return true if the light is on."""
41 """Return the brightness of the light."""
42 return int((self.
_unit_unit.get_dimmer_state() * 255) / 100)
46 """Instruct the light to turn on."""
47 if (val := kwargs.get(ATTR_BRIGHTNESS))
is not None:
49 val =
max(
int((val * 100) / 255), 1)
53 await self.
_unit_unit.set_dimmer_state(val)
57 """Instruct the light to turn off."""
58 await self.
_unit_unit.set_dimmer_state(0)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)