From 9f3f71d0c3a3af9484e7cab6e7288a98b5855f70 Mon Sep 17 00:00:00 2001 From: Volker Stolz Date: Wed, 1 Mar 2023 03:52:45 +0100 Subject: [PATCH] Introduce a UUID configuration option for API token (#88765) * Introduce a UUID configuration option for API token. (#86547) If the uuid is configured, it will be used in the HTTP headers. Otherwise, we'll hash the salted instance URL which should be good enough(tm). * Generate random 6-digit uuid on startup. --- homeassistant/components/entur_public_transport/sensor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/entur_public_transport/sensor.py b/homeassistant/components/entur_public_transport/sensor.py index 3e8b7bbe390..f5a954b16d4 100644 --- a/homeassistant/components/entur_public_transport/sensor.py +++ b/homeassistant/components/entur_public_transport/sensor.py @@ -2,6 +2,7 @@ from __future__ import annotations from datetime import datetime, timedelta +from random import randint from enturclient import EnturPublicTransportData import voluptuous as vol @@ -22,7 +23,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util import Throttle import homeassistant.util.dt as dt_util -API_CLIENT_NAME = "homeassistant-homeassistant" +API_CLIENT_NAME = "homeassistant-{}" CONF_STOP_IDS = "stop_ids" CONF_EXPAND_PLATFORMS = "expand_platforms" @@ -105,7 +106,7 @@ async def async_setup_platform( quays = [s for s in stop_ids if "Quay" in s] data = EnturPublicTransportData( - API_CLIENT_NAME, + API_CLIENT_NAME.format(str(randint(100000, 999999))), stops=stops, quays=quays, line_whitelist=line_whitelist,