1 """Support for lights connected with WMS WebControl pro."""
3 from __future__
import annotations
5 from datetime
import timedelta
8 from wmspro.const
import WMS_WebControl_pro_API_actionDescription
15 from .
import WebControlProConfigEntry
16 from .const
import BRIGHTNESS_SCALE
17 from .entity
import WebControlProGenericEntity
25 config_entry: WebControlProConfigEntry,
26 async_add_entities: AddEntitiesCallback,
28 """Set up the WMS based lights from a config entry."""
29 hub = config_entry.runtime_data
31 entities: list[WebControlProGenericEntity] = []
32 for dest
in hub.dests.values():
33 if dest.action(WMS_WebControl_pro_API_actionDescription.LightDimming):
35 elif dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch):
42 """Representation of a WMS based light."""
44 _attr_color_mode = ColorMode.ONOFF
45 _attr_supported_color_modes = {ColorMode.ONOFF}
49 """Return true if light is on."""
50 action = self.
_dest_dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch)
51 return action[
"onOffState"]
54 """Turn the light on."""
55 action = self.
_dest_dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch)
56 await action(onOffState=
True)
59 """Turn the light off."""
60 action = self.
_dest_dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch)
61 await action(onOffState=
False)
65 """Representation of a WMS-based dimmable light."""
67 _attr_color_mode = ColorMode.BRIGHTNESS
68 _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
72 """Return the brightness of this light between 1..255."""
73 action = self.
_dest_dest.action(
74 WMS_WebControl_pro_API_actionDescription.LightDimming
79 """Turn the dimmer on."""
80 if ATTR_BRIGHTNESS
not in kwargs:
84 action = self.
_dest_dest.action(
85 WMS_WebControl_pro_API_actionDescription.LightDimming
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, WebControlProConfigEntry config_entry, AddEntitiesCallback async_add_entities)
float brightness_to_value(tuple[float, float] low_high_range, int brightness)
int value_to_brightness(tuple[float, float] low_high_range, float value)