1 """Support for Firmata light output."""
3 from __future__
import annotations
14 from .board
import FirmataPinType
15 from .const
import CONF_INITIAL_STATE, CONF_PIN_MODE, DOMAIN
16 from .entity
import FirmataPinEntity
17 from .pin
import FirmataBoardPin, FirmataPinUsedException, FirmataPWMOutput
19 _LOGGER = logging.getLogger(__name__)
24 config_entry: ConfigEntry,
25 async_add_entities: AddEntitiesCallback,
27 """Set up the Firmata lights."""
30 board = hass.data[DOMAIN][config_entry.entry_id]
31 for light
in board.lights:
33 pin_mode = light[CONF_PIN_MODE]
34 initial = light[CONF_INITIAL_STATE]
35 minimum = light[CONF_MINIMUM]
36 maximum = light[CONF_MAXIMUM]
40 except FirmataPinUsedException:
42 "Could not setup light on pin %s since pin already in use",
46 name = light[CONF_NAME]
47 light_entity =
FirmataLight(api, config_entry, name, pin)
48 new_entities.append(light_entity)
54 """Representation of a light on a Firmata board."""
56 _attr_color_mode = ColorMode.BRIGHTNESS
57 _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
62 config_entry: ConfigEntry,
66 """Initialize the light pin entity."""
67 super().
__init__(api, config_entry, name, pin)
74 await self.
_api_api.start_pin()
78 """Return true if light is on."""
79 return self.
_api_api.state > 0
83 """Return the brightness of the light."""
84 return self.
_api_api.state
88 level = kwargs.get(ATTR_BRIGHTNESS, self.
_last_on_level_last_on_level)
89 await self.
_api_api.set_level(level)
95 await self.
_api_api.set_level(0)
None async_turn_on(self, **Any kwargs)
None __init__(self, FirmataBoardPin api, ConfigEntry config_entry, str name, FirmataPinType pin)
None async_turn_off(self, **Any kwargs)
None async_added_to_hass(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)