def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the brunt platform.""" username = config[CONF_USERNAME] password = config[CONF_PASSWORD] bapi = BruntAPI(username=username, password=password) try: things = bapi.getThings()["things"] if not things: _LOGGER.error("No things present in account") else: add_entities( [ BruntDevice(bapi, thing["NAME"], thing["thingUri"]) for thing in things ], True, ) except (TypeError, KeyError, NameError, ValueError) as ex: _LOGGER.error("%s", ex) hass.components.persistent_notification.create( "Error: {ex}<br />You will need to restart hass after fixing.", title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID, )
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the brunt platform.""" # pylint: disable=no-name-in-module from brunt import BruntAPI username = config[CONF_USERNAME] password = config[CONF_PASSWORD] bapi = BruntAPI(username=username, password=password) try: things = bapi.getThings()['things'] if not things: _LOGGER.error("No things present in account.") else: add_entities([ BruntDevice(bapi, thing['NAME'], thing['thingUri']) for thing in things ], True) except (TypeError, KeyError, NameError, ValueError) as ex: _LOGGER.error("%s", ex) hass.components.persistent_notification.create( 'Error: {}<br />' 'You will need to restart hass after fixing.' ''.format(ex), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the brunt platform.""" username = config[CONF_USERNAME] password = config[CONF_PASSWORD] bapi = BruntAPI(username=username, password=password) try: if not (things := bapi.getThings()["things"]): _LOGGER.error("No things present in account") else:
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the brunt platform.""" # pylint: disable=no-name-in-module from brunt import BruntAPI username = config[CONF_USERNAME] password = config[CONF_PASSWORD] bapi = BruntAPI(username=username, password=password) try: things = bapi.getThings()['things'] if not things: _LOGGER.error("No things present in account.") else: add_devices([BruntDevice( bapi, thing['NAME'], thing['thingUri']) for thing in things], True) except (TypeError, KeyError, NameError, ValueError) as ex: _LOGGER.error("%s", ex) hass.components.persistent_notification.create( 'Error: {}<br />' 'You will need to restart hass after fixing.' ''.format(ex), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID)