mirror of
https://github.com/Dielee/volvo2mqtt.git
synced 2026-08-13 19:29:52 +02:00
Try to fix not saveable OTP Code
This commit is contained in:
+1
-1
@@ -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
@@ -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
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user