forked from peter/volvo2mqtt
Fix unlockstate for multiple car usage
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
name: "Volvo2Mqtt"
|
name: "Volvo2Mqtt"
|
||||||
description: "Volvo AAOS MQTT bridge"
|
description: "Volvo AAOS MQTT bridge"
|
||||||
version: "1.4.3"
|
version: "1.4.4"
|
||||||
slug: "volvo2mqtt"
|
slug: "volvo2mqtt"
|
||||||
init: false
|
init: false
|
||||||
url: "https://github.com/Dielee/volvo2mqtt"
|
url: "https://github.com/Dielee/volvo2mqtt"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
from config import settings
|
from config import settings
|
||||||
|
|
||||||
VERSION = "v1.4.3"
|
VERSION = "v1.4.4"
|
||||||
|
|
||||||
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
|
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
|
||||||
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
|
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
|
||||||
|
|||||||
+5
-3
@@ -79,10 +79,10 @@ def on_message(client, userdata, msg):
|
|||||||
elif "lock_status" in msg.topic:
|
elif "lock_status" in msg.topic:
|
||||||
if payload == "LOCK":
|
if payload == "LOCK":
|
||||||
volvo.api_call(CAR_LOCK_URL, "POST", vin)
|
volvo.api_call(CAR_LOCK_URL, "POST", vin)
|
||||||
update_car_data(True, {"entity_id": "lock_status", "state": "LOCKED"})
|
update_car_data(True, {"entity_id": "lock_status", "vin": vin, "state": "LOCKED"})
|
||||||
elif payload == "UNLOCK":
|
elif payload == "UNLOCK":
|
||||||
volvo.api_call(CAR_UNLOCK_URL, "POST", vin)
|
volvo.api_call(CAR_UNLOCK_URL, "POST", vin)
|
||||||
update_car_data(True, {"entity_id": "lock_status", "state": "UNLOCKED"})
|
update_car_data(True, {"entity_id": "lock_status", "vin": vin, "state": "UNLOCKED"})
|
||||||
elif "update_data" in msg.topic:
|
elif "update_data" in msg.topic:
|
||||||
if payload == "PRESS":
|
if payload == "PRESS":
|
||||||
update_car_data(True)
|
update_car_data(True)
|
||||||
@@ -106,9 +106,11 @@ def update_car_data(force_update=False, overwrite={}):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
ov_entity_id = ""
|
ov_entity_id = ""
|
||||||
|
ov_vin = ""
|
||||||
ov_state = ""
|
ov_state = ""
|
||||||
if bool(overwrite):
|
if bool(overwrite):
|
||||||
ov_entity_id = overwrite["entity_id"]
|
ov_entity_id = overwrite["entity_id"]
|
||||||
|
ov_vin = overwrite["vin"]
|
||||||
ov_state = overwrite["state"]
|
ov_state = overwrite["state"]
|
||||||
|
|
||||||
if entity["id"] == "climate_status":
|
if entity["id"] == "climate_status":
|
||||||
@@ -116,7 +118,7 @@ def update_car_data(force_update=False, overwrite={}):
|
|||||||
elif entity["id"] == "last_data_update":
|
elif entity["id"] == "last_data_update":
|
||||||
state = last_data_update
|
state = last_data_update
|
||||||
else:
|
else:
|
||||||
if entity["id"] == ov_entity_id:
|
if entity["id"] == ov_entity_id and vin == ov_vin:
|
||||||
state = ov_state
|
state = ov_state
|
||||||
else:
|
else:
|
||||||
state = volvo.api_call(entity["url"], "GET", vin, entity["id"], force_update)
|
state = volvo.api_call(entity["url"], "GET", vin, entity["id"], force_update)
|
||||||
|
|||||||
Reference in New Issue
Block a user