Use location name on self hosted Ecovacs config entries (#115294)
parent
2c651e190f
commit
fced9eb4b5
|
@ -71,7 +71,7 @@ async def _validate_input(
|
||||||
if errors:
|
if errors:
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
device_id = get_client_device_id()
|
device_id = get_client_device_id(hass, rest_url is not None)
|
||||||
country = user_input[CONF_COUNTRY]
|
country = user_input[CONF_COUNTRY]
|
||||||
rest_config = create_rest_config(
|
rest_config = create_rest_config(
|
||||||
aiohttp_client.async_get_clientsession(hass),
|
aiohttp_client.async_get_clientsession(hass),
|
||||||
|
|
|
@ -43,7 +43,8 @@ class EcovacsController:
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
self._devices: list[Device] = []
|
self._devices: list[Device] = []
|
||||||
self.legacy_devices: list[VacBot] = []
|
self.legacy_devices: list[VacBot] = []
|
||||||
self._device_id = get_client_device_id()
|
rest_url = config.get(CONF_OVERRIDE_REST_URL)
|
||||||
|
self._device_id = get_client_device_id(hass, rest_url is not None)
|
||||||
country = config[CONF_COUNTRY]
|
country = config[CONF_COUNTRY]
|
||||||
self._continent = get_continent(country)
|
self._continent = get_continent(country)
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ class EcovacsController:
|
||||||
aiohttp_client.async_get_clientsession(self._hass),
|
aiohttp_client.async_get_clientsession(self._hass),
|
||||||
device_id=self._device_id,
|
device_id=self._device_id,
|
||||||
alpha_2_country=country,
|
alpha_2_country=country,
|
||||||
override_rest_url=config.get(CONF_OVERRIDE_REST_URL),
|
override_rest_url=rest_url,
|
||||||
),
|
),
|
||||||
config[CONF_USERNAME],
|
config[CONF_USERNAME],
|
||||||
md5(config[CONF_PASSWORD]),
|
md5(config[CONF_PASSWORD]),
|
||||||
|
|
|
@ -9,7 +9,8 @@ from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from deebot_client.capabilities import Capabilities
|
from deebot_client.capabilities import Capabilities
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
from .entity import (
|
from .entity import (
|
||||||
EcovacsCapabilityEntityDescription,
|
EcovacsCapabilityEntityDescription,
|
||||||
|
@ -21,8 +22,11 @@ if TYPE_CHECKING:
|
||||||
from .controller import EcovacsController
|
from .controller import EcovacsController
|
||||||
|
|
||||||
|
|
||||||
def get_client_device_id() -> str:
|
def get_client_device_id(hass: HomeAssistant, self_hosted: bool) -> str:
|
||||||
"""Get client device id."""
|
"""Get client device id."""
|
||||||
|
if self_hosted:
|
||||||
|
return f"HA-{slugify(hass.config.location_name)}"
|
||||||
|
|
||||||
return "".join(
|
return "".join(
|
||||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(8)
|
random.choice(string.ascii_uppercase + string.digits) for _ in range(8)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue