Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Uptime Robot binary_sensors."""
up_robot = UptimeRobot()
api_key = config.get(CONF_API_KEY)
monitors = up_robot.getMonitors(api_key)
devices = []
if not monitors or monitors.get("stat") != "ok":
_LOGGER.error("Error connecting to Uptime Robot")
return
for monitor in monitors["monitors"]:
devices.append(
UptimeRobotBinarySensor(
api_key,
up_robot,
monitor["id"],
monitor["friendly_name"],
monitor["url"],