def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Discogs sensor.""" import discogs_client token = config[CONF_TOKEN] name = config[CONF_NAME] try: discogs_client = discogs_client.Client(SERVER_SOFTWARE, user_token=token) discogs_data = { 'user': discogs_client.identity().name, 'folders': discogs_client.identity().collection_folders, 'collection_count': discogs_client.identity().num_collection, 'wantlist_count': discogs_client.identity().num_wantlist } except discogs_client.exceptions.HTTPError: _LOGGER.error("API token is not valid") return sensors = [] for sensor_type in config.get(CONF_MONITORED_CONDITIONS): sensors.append(DiscogsSensor(discogs_data, name, sensor_type)) add_entities(sensors, True)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Discogs sensor.""" import discogs_client token = config[CONF_TOKEN] name = config[CONF_NAME] try: discogs_client = discogs_client.Client( SERVER_SOFTWARE, user_token=token) discogs_data = { 'user': discogs_client.identity().name, 'folders': discogs_client.identity().collection_folders, 'collection_count': discogs_client.identity().num_collection, 'wantlist_count': discogs_client.identity().num_wantlist } except discogs_client.exceptions.HTTPError: _LOGGER.error("API token is not valid") return sensors = [] for sensor_type in config.get(CONF_MONITORED_CONDITIONS): sensors.append(DiscogsSensor(discogs_data, name, sensor_type)) add_entities(sensors, True)