Compare commits

...
2 Commits
Author SHA1 Message Date
Dielee c6ddd71021 Bump addon version 2024-05-28 08:26:38 +02:00
Dielee 1f0612ca4a Try to fix not saveable OTP Code 2024-05-28 08:26:18 +02:00
4 changed files with 22 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt" name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge" description: "Volvo AAOS MQTT bridge"
version: "1.9.1" version: "1.9.2"
slug: "volvo2mqtt" slug: "volvo2mqtt"
init: false init: false
url: "https://github.com/Dielee/volvo2mqtt" url: "https://github.com/Dielee/volvo2mqtt"
+1 -1
View File
@@ -1,6 +1,6 @@
from config import settings from config import settings
VERSION = "v1.9.1" VERSION = "v1.9.2"
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2" OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.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(): def create_otp_input():
state_topic = otp_mqtt_topic + "/state"
config = { config = {
"name": "Volvo OTP", "name": "Volvo OTP",
"object_id": f"volvo_otp", "object_id": f"volvo_otp",
"schema": "state", "schema": "state",
"command_topic": otp_mqtt_topic, "command_topic": otp_mqtt_topic,
"unique_id": f"volvoAAOS2mqtt_otp", "state_topic": state_topic,
"pattern": "\d{6}", "unique_id": "volvoAAOS2mqtt_otp",
"icon": "mdi:two-factor-authentication" "pattern": r"\d{6}",
"icon": "mdi:two-factor-authentication",
"mode": "text"
} }
mqtt_client.publish( mqtt_client.publish(
f"homeassistant/text/volvoAAOS2mqtt/volvo_otp/config", "homeassistant/text/volvoAAOS2mqtt/volvo_otp/config",
json.dumps(config), json.dumps(config),
retain=True retain=True
) )
def delete_otp_input(): mqtt_client.publish(
topic = "homeassistant/text/volvoAAOS2mqtt/volvo_otp/config" state_topic,
mqtt_client.publish(topic, payload="", retain=True) "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): 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: if not mqtt.otp_code:
raise Exception ("No OTP found, exting...") raise Exception ("No OTP found, exting...")
mqtt.delete_otp_input() mqtt.set_otp_state()
auth = auth_session.post(next_url, data=json.dumps(body)) auth = auth_session.post(next_url, data=json.dumps(body))
if auth.status_code == 200: if auth.status_code == 200:
return auth.json() return auth.json()