async def main(): global el, args args = parse_args() logging.basicConfig(level=args.verbose) el = pyeverlights.EverLights(args.ip) await args.func() await el.close()
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EverLights lights from configuration.yaml.""" import pyeverlights lights = [] for ipaddr in config[CONF_HOSTS]: api = pyeverlights.EverLights(ipaddr, async_get_clientsession(hass)) try: status = await api.get_status() effects = await api.get_all_patterns() except pyeverlights.ConnectionError: raise PlatformNotReady else: lights.append(EverLightsLight(api, pyeverlights.ZONE_1, status, effects)) lights.append(EverLightsLight(api, pyeverlights.ZONE_2, status, effects)) async_add_entities(lights)
async def async_setup_platform( hass: HomeAssistant, config: ConfigType, async_add_entities: AddEntitiesCallback, discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the EverLights lights from configuration.yaml.""" lights = [] for ipaddr in config[CONF_HOSTS]: api = pyeverlights.EverLights(ipaddr, async_get_clientsession(hass)) try: status = await api.get_status() effects = await api.get_all_patterns() except pyeverlights.ConnectionError as err: raise PlatformNotReady from err else: lights.append( EverLightsLight(api, pyeverlights.ZONE_1, status, effects)) lights.append( EverLightsLight(api, pyeverlights.ZONE_2, status, effects)) async_add_entities(lights)