Skip to content

Commit

Permalink
Use correct mobile id
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Mar 29, 2024
1 parent 11da4eb commit 53691e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions pyhon/connection/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@


class MQTTClient:
def __init__(self, hon: "Hon"):
def __init__(self, hon: "Hon", mobile_id: str) -> None:
self._client: mqtt5.Client | None = None
self._hon = hon
self._mobile_id = mobile_id or const.MOBILE_ID
self._api = hon.api
self._appliances = hon.appliances
self._connection = False
Expand Down Expand Up @@ -88,10 +89,10 @@ def _on_publish_received(self, data: mqtt5.PublishReceivedData) -> None:
)
appliance.sync_params_to_command("settings")
self._hon.notify()
elif topic and "connected" in topic:
_LOGGER.info("Connected %s", appliance.nick_name)
elif topic and "disconnected" in topic:
_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:
_LOGGER.info("Discovered %s", appliance.nick_name)
_LOGGER.info("%s - %s", topic, payload)
Expand All @@ -103,7 +104,7 @@ async def _start(self) -> None:
auth_authorizer_signature=await self._api.load_aws_token(),
auth_token_key_name="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_connection_success=self._on_lifecycle_connection_success,
on_lifecycle_attempting_connect=self._on_lifecycle_attempting_connect,
Expand Down
3 changes: 2 additions & 1 deletion pyhon/hon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
_LOGGER = logging.getLogger(__name__)


# pylint: disable=too-many-instance-attributes
class Hon:
def __init__(
self,
Expand Down Expand Up @@ -124,7 +125,7 @@ async def setup(self) -> None:
for appliance in await api.load_appliances():
await self._create_appliance(appliance, api)
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:
self._notify_function = notify_function
Expand Down

0 comments on commit 53691e3

Please sign in to comment.