Use correct mobile id

This commit is contained in:
Andre Basche 2024-03-29 13:21:49 +01:00
parent 11da4ebfbc
commit 53691e383e
2 changed files with 7 additions and 5 deletions

View file

@ -17,9 +17,10 @@ _LOGGER = logging.getLogger(__name__)
class MQTTClient: class MQTTClient:
def __init__(self, hon: "Hon"): def __init__(self, hon: "Hon", mobile_id: str) -> None:
self._client: mqtt5.Client | None = None self._client: mqtt5.Client | None = None
self._hon = hon self._hon = hon
self._mobile_id = mobile_id or const.MOBILE_ID
self._api = hon.api self._api = hon.api
self._appliances = hon.appliances self._appliances = hon.appliances
self._connection = False self._connection = False
@ -88,10 +89,10 @@ class MQTTClient:
) )
appliance.sync_params_to_command("settings") appliance.sync_params_to_command("settings")
self._hon.notify() self._hon.notify()
elif topic and "connected" in topic:
_LOGGER.info("Connected %s", appliance.nick_name)
elif topic and "disconnected" in topic: elif topic and "disconnected" in topic:
_LOGGER.info("Disconnected %s", appliance.nick_name) _LOGGER.info("Disconnected %s", appliance.nick_name)
elif topic and "connected" in topic:
_LOGGER.info("Connected %s", appliance.nick_name)
elif topic and "discovery" in topic: elif topic and "discovery" in topic:
_LOGGER.info("Discovered %s", appliance.nick_name) _LOGGER.info("Discovered %s", appliance.nick_name)
_LOGGER.info("%s - %s", topic, payload) _LOGGER.info("%s - %s", topic, payload)
@ -103,7 +104,7 @@ class MQTTClient:
auth_authorizer_signature=await self._api.load_aws_token(), auth_authorizer_signature=await self._api.load_aws_token(),
auth_token_key_name="token", auth_token_key_name="token",
auth_token_value=self._api.auth.id_token, auth_token_value=self._api.auth.id_token,
client_id=f"{const.MOBILE_ID}_{secrets.token_hex(8)}", client_id=f"{self._mobile_id}_{secrets.token_hex(8)}",
on_lifecycle_stopped=self._on_lifecycle_stopped, on_lifecycle_stopped=self._on_lifecycle_stopped,
on_lifecycle_connection_success=self._on_lifecycle_connection_success, on_lifecycle_connection_success=self._on_lifecycle_connection_success,
on_lifecycle_attempting_connect=self._on_lifecycle_attempting_connect, on_lifecycle_attempting_connect=self._on_lifecycle_attempting_connect,

View file

@ -16,6 +16,7 @@ from pyhon.exceptions import NoAuthenticationException
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
# pylint: disable=too-many-instance-attributes
class Hon: class Hon:
def __init__( def __init__(
self, self,
@ -124,7 +125,7 @@ class Hon:
for appliance in await api.load_appliances(): for appliance in await api.load_appliances():
await self._create_appliance(appliance, api) await self._create_appliance(appliance, api)
if not self._mqtt_client: if not self._mqtt_client:
self._mqtt_client = await MQTTClient(self).create() self._mqtt_client = await MQTTClient(self, self._mobile_id).create()
def subscribe_updates(self, notify_function: Callable[[Any], None]) -> None: def subscribe_updates(self, notify_function: Callable[[Any], None]) -> None:
self._notify_function = notify_function self._notify_function = notify_function