Try to fix not saveable OTP Code

This commit is contained in:
Dielee
2024-05-28 08:26:18 +02:00
parent 6306c9a4b3
commit 1f0612ca4a
3 changed files with 21 additions and 9 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
from config import settings
VERSION = "v1.9.1"
VERSION = "v1.9.2"
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2"
+19 -7
View File
@@ -47,25 +47,37 @@ def connect():
def create_otp_input():
state_topic = otp_mqtt_topic + "/state"
config = {
"name": "Volvo OTP",
"object_id": f"volvo_otp",
"schema": "state",
"command_topic": otp_mqtt_topic,
"unique_id": f"volvoAAOS2mqtt_otp",
"pattern": "\d{6}",
"icon": "mdi:two-factor-authentication"
"state_topic": state_topic,
"unique_id": "volvoAAOS2mqtt_otp",
"pattern": r"\d{6}",
"icon": "mdi:two-factor-authentication",
"mode": "text"
}
mqtt_client.publish(
f"homeassistant/text/volvoAAOS2mqtt/volvo_otp/config",
"homeassistant/text/volvoAAOS2mqtt/volvo_otp/config",
json.dumps(config),
retain=True
)
def delete_otp_input():
topic = "homeassistant/text/volvoAAOS2mqtt/volvo_otp/config"
mqtt_client.publish(topic, payload="", retain=True)
mqtt_client.publish(
state_topic,
"000000",
retain=True
)
def set_otp_state():
mqtt_client.publish(
otp_mqtt_topic + "/state",
otp_code,
retain=True
)
def send_car_images(vin, data, device):
+1 -1
View File
@@ -156,7 +156,7 @@ def send_otp(auth_session, data):
if not mqtt.otp_code:
raise Exception ("No OTP found, exting...")
mqtt.delete_otp_input()
mqtt.set_otp_state()
auth = auth_session.post(next_url, data=json.dumps(body))
if auth.status_code == 200:
return auth.json()