1 """Linear garage door light."""
5 from linear_garage_door
import Linear
12 from .const
import DOMAIN
13 from .coordinator
import LinearUpdateCoordinator
14 from .entity
import LinearEntity
16 SUPPORTED_SUBDEVICES = [
"Light"]
21 config_entry: ConfigEntry,
22 async_add_entities: AddEntitiesCallback,
24 """Set up Linear Garage Door cover."""
25 coordinator: LinearUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
26 data = coordinator.data
31 device_name=data[device_id].name,
33 coordinator=coordinator,
36 for subdev
in data[device_id].subdevices
37 if subdev
in SUPPORTED_SUBDEVICES
42 """Light for Linear devices."""
44 _attr_color_mode = ColorMode.BRIGHTNESS
45 _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
46 _attr_translation_key =
"light"
50 """Return if the light is on or not."""
55 """Return the brightness of the light."""
56 return round(
int(self.
sub_devicesub_device[
"On_P"]) / 100 * 255)
59 """Turn on the light."""
61 async
def _turn_on(linear: Linear) ->
None:
62 """Turn on the light."""
65 elif ATTR_BRIGHTNESS
in kwargs:
66 brightness = round((kwargs[ATTR_BRIGHTNESS] / 255) * 100)
67 await linear.operate_device(
71 await self.coordinator.
execute(_turn_on)
74 """Turn off the light."""
77 lambda linear: linear.operate_device(
dict[str, str] sub_device(self)
int|None brightness(self)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
def execute(hass, filename, source, data=None, return_response=False)