Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor corrections and more checking for exceptions #267

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
better checking on received update_interval #270
ivanfmartinez committed Nov 7, 2024
commit 507201428225cc9b4969b86f6f83c261c4141820
15 changes: 9 additions & 6 deletions src/mqtt.py
Original file line number Diff line number Diff line change
@@ -187,12 +187,15 @@ def on_message(client, userdata, msg):
if payload == "PRESS":
update_car_data(True)
elif "update_interval" in msg.topic:
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()
try:
update_interval = int(payload)
if update_interval >= 60 or update_interval == -1:
settings.update({"updateInterval": int(update_interval)})
else:
logging.warning(f"Interval {update_interval} seconds is to low. Doing nothing!")
update_car_data()
except ValueError as error:
logging.error(f"Unable to change update_interval {error} payload={payload}")
elif "schedule" in msg.topic:
try:
d = json.loads(payload)