1 """Support for Avion dimmers."""
3 from __future__
import annotations
9 import voluptuous
as vol
13 PLATFORM_SCHEMA
as LIGHT_PLATFORM_SCHEMA,
30 DEVICE_SCHEMA = vol.Schema(
32 vol.Required(CONF_API_KEY): cv.string,
33 vol.Optional(CONF_ID): cv.positive_int,
34 vol.Optional(CONF_NAME): cv.string,
38 PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA.extend(
40 vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA},
41 vol.Optional(CONF_USERNAME): cv.string,
42 vol.Optional(CONF_PASSWORD): cv.string,
50 add_entities: AddEntitiesCallback,
51 discovery_info: DiscoveryInfoType |
None =
None,
53 """Set up an Avion switch."""
54 avion = importlib.import_module(
"avion")
60 passphrase=device_config[CONF_API_KEY],
61 name=device_config.get(CONF_NAME),
62 object_id=device_config.get(CONF_ID),
66 for address, device_config
in config[CONF_DEVICES].items()
68 if CONF_USERNAME
in config
and CONF_PASSWORD
in config:
71 for device
in avion.get_devices(
72 config[CONF_USERNAME], config[CONF_PASSWORD]
80 """Representation of an Avion light."""
82 _attr_support_color_mode = ColorMode.BRIGHTNESS
83 _attr_support_color_modes = {ColorMode.BRIGHTNESS}
84 _attr_should_poll =
False
85 _attr_assumed_state =
True
89 """Initialize the light."""
96 """Set the state of this lamp to the provided brightness."""
97 avion = importlib.import_module(
"avion")
101 initial = time.monotonic()
103 if time.monotonic() - initial >= 10:
106 self.
_switch_switch.set_brightness(brightness)
108 except avion.AvionException:
113 """Turn the specified or all lights on."""
114 if (brightness := kwargs.get(ATTR_BRIGHTNESS))
is not None:
121 """Turn the specified or all lights off."""
def set_state(self, brightness)
def __init__(self, device)
None turn_off(self, **Any kwargs)
None turn_on(self, **Any kwargs)
int|None brightness(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)