From 417514a22fdc63eefe4e15057a1a2a78cef45cda Mon Sep 17 00:00:00 2001 From: topsworld Date: Fri, 10 Jan 2025 17:03:19 +0800 Subject: [PATCH] feat: improve miot cloud logic --- custom_components/xiaomi_home/miot/miot_cloud.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_home/miot/miot_cloud.py b/custom_components/xiaomi_home/miot/miot_cloud.py index 4c076fe..b24f8f2 100644 --- a/custom_components/xiaomi_home/miot/miot_cloud.py +++ b/custom_components/xiaomi_home/miot/miot_cloud.py @@ -47,6 +47,7 @@ MIoT http client. """ import asyncio import base64 +import hashlib import json import logging import re @@ -136,7 +137,9 @@ class MIoTOauthClient: 'redirect_uri': redirect_url or self._redirect_url, 'client_id': self._client_id, 'response_type': 'code', - 'device_id': self._device_id + 'device_id': self._device_id, + 'state': hashlib.sha1( + f'd={self._device_id}'.encode('utf-8')).hexdigest() } if state: params['state'] = state