Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
hass, config, async_add_entities, discovery_info=None):
"""Create the Tautulli sensor."""
from pytautulli import Tautulli
name = config.get(CONF_NAME)
host = config[CONF_HOST]
port = config.get(CONF_PORT)
path = config.get(CONF_PATH)
api_key = config[CONF_API_KEY]
monitored_conditions = config.get(CONF_MONITORED_CONDITIONS)
user = config.get(CONF_MONITORED_USERS)
use_ssl = config.get(CONF_SSL)
verify_ssl = config.get(CONF_VERIFY_SSL)
session = async_get_clientsession(hass, verify_ssl)
tautulli = TautulliData(Tautulli(
host, port, api_key, hass.loop, session, use_ssl, path))
if not await tautulli.test_connection():
raise PlatformNotReady
sensor = [TautulliSensor(tautulli, name, monitored_conditions, user)]
async_add_entities(sensor, True)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Create the Tautulli sensor."""
name = config.get(CONF_NAME)
host = config[CONF_HOST]
port = config.get(CONF_PORT)
path = config.get(CONF_PATH)
api_key = config[CONF_API_KEY]
monitored_conditions = config.get(CONF_MONITORED_CONDITIONS)
user = config.get(CONF_MONITORED_USERS)
use_ssl = config.get(CONF_SSL)
verify_ssl = config.get(CONF_VERIFY_SSL)
session = async_get_clientsession(hass, verify_ssl)
tautulli = TautulliData(
Tautulli(host, port, api_key, hass.loop, session, use_ssl, path)
)
if not await tautulli.test_connection():
raise PlatformNotReady
sensor = [TautulliSensor(tautulli, name, monitored_conditions, user)]
async_add_entities(sensor, True)