Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Revert "Bump version"
Browse files Browse the repository at this point in the history
This reverts commit 1574fa9
  • Loading branch information
Dielee committed Jun 24, 2023
1 parent 1574fa9 commit 1d37b3a
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def on_message(client, userdata, msg):
elif "lock_status" in msg.topic:
if payload == "LOCK":
volvo.api_call(CAR_LOCK_URL, "POST", vin)
update_car_data(True, {"entity_id": "lock_status", "state": "LOCKED"})
update_car_data(True)
elif payload == "UNLOCK":
volvo.api_call(CAR_UNLOCK_URL, "POST", vin)
update_car_data(True, {"entity_id": "lock_status", "state": "UNLOCKED"})
update_car_data(True)
elif "update_data" in msg.topic:
if payload == "PRESS":
update_car_data(True)
Expand All @@ -88,29 +88,20 @@ def update_loop():
time.sleep(settings["updateInterval"])


def update_car_data(force_update=False, overwrite={}):
def update_car_data(force_update=False):
global last_data_update
last_data_update = format_datetime(datetime.now(), format="medium", locale=settings["babelLocale"])
for vin in volvo.vins:
for entity in volvo.supported_endpoints[vin]:
if entity["domain"] == "button":
continue

ov_entity_id = ""
ov_state = ""
if bool(overwrite):
ov_entity_id = overwrite["entity_id"]
ov_state = overwrite["state"]

if entity["id"] == "climate_status":
state = assumed_climate_state[vin]
elif entity["id"] == "last_data_update":
state = last_data_update
else:
if entity["id"] == ov_entity_id:
state = ov_state
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)

if entity["domain"] == "device_tracker":
topic = f"homeassistant/{entity['domain']}/{vin}_{entity['id']}/attributes"
Expand Down

0 comments on commit 1d37b3a

Please sign in to comment.