1 """Support for FutureNow Ethernet unit outputs as Lights."""
3 from __future__
import annotations
8 import voluptuous
as vol
12 PLATFORM_SCHEMA
as LIGHT_PLATFORM_SCHEMA,
22 CONF_DRIVER =
"driver"
23 CONF_DRIVER_FNIP6X10AD =
"FNIP6x10ad"
24 CONF_DRIVER_FNIP8X10A =
"FNIP8x10a"
25 CONF_DRIVER_TYPES = [CONF_DRIVER_FNIP6X10AD, CONF_DRIVER_FNIP8X10A]
27 DEVICE_SCHEMA = vol.Schema(
29 vol.Required(CONF_NAME): cv.string,
30 vol.Optional(
"dimmable", default=
False): cv.boolean,
34 PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA.extend(
36 vol.Required(CONF_DRIVER): vol.In(CONF_DRIVER_TYPES),
37 vol.Required(CONF_HOST): cv.string,
38 vol.Required(CONF_PORT): cv.port,
39 vol.Required(CONF_DEVICES): {cv.string: DEVICE_SCHEMA},
47 add_entities: AddEntitiesCallback,
48 discovery_info: DiscoveryInfoType |
None =
None,
50 """Set up the light platform for each FutureNow unit."""
52 for channel, device_config
in config[CONF_DEVICES].items():
54 device[
"name"] = device_config[CONF_NAME]
55 device[
"dimmable"] = device_config[
"dimmable"]
56 device[
"channel"] = channel
57 device[
"driver"] = config[CONF_DRIVER]
58 device[
"host"] = config[CONF_HOST]
59 device[
"port"] = config[CONF_PORT]
66 """Convert the given Home Assistant light level (0-255) to FutureNow (0-100)."""
67 return round((level * 100) / 255)
71 """Convert the given FutureNow (0-100) light level to Home Assistant (0-255)."""
72 return int((level * 255) / 100)
76 """Representation of an FutureNow light."""
79 """Initialize the light."""
80 self.
_name_name = device[
"name"]
87 if device[
"driver"] == CONF_DRIVER_FNIP6X10AD:
88 self.
_light_light = pyfnip.FNIP6x2adOutput(
89 device[
"host"], device[
"port"], self.
_channel_channel
91 if device[
"driver"] == CONF_DRIVER_FNIP8X10A:
92 self.
_light_light = pyfnip.FNIP8x10aOutput(
93 device[
"host"], device[
"port"], self.
_channel_channel
98 """Return the name of the device if any."""
99 return self.
_name_name
103 """Return true if device is on."""
108 """Return the brightness of this light between 0..255."""
113 """Return the color mode of the light."""
115 return ColorMode.BRIGHTNESS
116 return ColorMode.ONOFF
120 """Flag supported color modes."""
124 """Turn the light on."""
132 """Turn the light off."""
138 """Fetch new state data for this light."""
None turn_on(self, **Any kwargs)
ColorMode color_mode(self)
None turn_off(self, **Any kwargs)
set[ColorMode] supported_color_modes(self)
def __init__(self, device)
ColorMode|str|None color_mode(self)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)
def to_futurenow_level(level)