Skip to content

Commit

Permalink
Add option to disable updates #160
Browse files Browse the repository at this point in the history
  • Loading branch information
Dielee committed Jan 23, 2024
1 parent e444b6a commit 3d2285f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v1.8.26
### 🚀 Features:

- Add option to disable updates #160

## v1.8.25
### 🚀 Features:

Expand Down
2 changes: 1 addition & 1 deletion src/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge"
version: "1.8.24"
version: "1.8.26"
slug: "volvo2mqtt"
init: false
url: "https://github.com/Dielee/volvo2mqtt"
Expand Down
4 changes: 2 additions & 2 deletions src/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from config import settings

VERSION = "v1.8.25"
VERSION = "v1.8.26"

OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles"
Expand Down Expand Up @@ -132,7 +132,7 @@
{"name": "Service warning status", "domain": "sensor", "id": "service_warning_status", "icon": "alert-outline", "url": VEHICLE_DIAGNOSTICS_URL},
{"name": "Washer Fluid Level warning", "domain": "sensor", "id": "washer_fluid_warning", "icon": "alert-outline", "url": VEHICLE_DIAGNOSTICS_URL},
{"name": "API Backend status", "domain": "sensor", "id": "api_backend_status", "icon": "alert"},
{"name": "Update Interval", "domain": "number", "id": "update_interval", "unit": "seconds", "icon": "timer", "min": 60, "max": 600, "mode": "box"},
{"name": "Update Interval", "domain": "number", "id": "update_interval", "unit": "seconds", "icon": "timer", "min": -1, "max": 600, "mode": "box"},
{"name": "Warnings", "domain": "sensor", "id": "warnings", "icon": "alert", "url": WARNINGS_URL}
]

Expand Down
21 changes: 15 additions & 6 deletions src/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ def on_message(client, userdata, msg):
if payload == "PRESS":
update_car_data(True)
elif "update_interval" in msg.topic:
settings.update({"updateInterval": int(payload)})
update_interval = int(payload)
if update_interval >= 60 or update_interval == -1:
settings.update({"updateInterval": int(update_interval)})
else:
logging.warning("Interval " + str(update_interval) + " seconds is to low. Doing nothing!")
update_car_data()
elif "schedule" in msg.topic:
try:
d = json.loads(payload)
Expand Down Expand Up @@ -216,11 +221,15 @@ def start_climate(vin):
def update_loop():
create_ha_devices()
while True:
logging.info("Sending mqtt update...")
send_heartbeat()
update_car_data()
logging.info("Mqtt update done. Next run in " + str(settings["updateInterval"]) + " seconds.")
time.sleep(settings["updateInterval"])
if settings["updateInterval"] > 0:
logging.info("Sending mqtt update...")
send_heartbeat()
update_car_data()
logging.info("Mqtt update done. Next run in " + str(settings["updateInterval"]) + " seconds.")
time.sleep(settings["updateInterval"])
else:
logging.info("Data update is disabled, doing nothing for 30 seconds")
time.sleep(30)


def update_car_data(force_update=False, overwrite={}):
Expand Down

0 comments on commit 3d2285f

Please sign in to comment.