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

Commit

Permalink
Add mqtt broker port option
Browse files Browse the repository at this point in the history
  • Loading branch information
Dielee committed Jun 24, 2023
1 parent 1d37b3a commit a51ba25
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
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.4.0"
version: "1.4.1"
slug: "volvo2mqtt"
init: false
url: "https://github.com/Dielee/volvo2mqtt"
Expand Down
2 changes: 1 addition & 1 deletion src/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from config import settings

VERSION = "v1.4.0"
VERSION = "v1.4.1"

OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
Expand Down
9 changes: 8 additions & 1 deletion src/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import paho.mqtt.client as mqtt
import json
import volvo
from util import keys_exists
from threading import Thread, Timer
from datetime import datetime
from babel.dates import format_datetime
Expand All @@ -21,7 +22,13 @@ def connect():
client = mqtt.Client("volvoAAOS2mqtt")
if settings["mqtt"]["username"] and settings["mqtt"]["password"]:
client.username_pw_set(settings["mqtt"]["username"], settings["mqtt"]["password"])
client.connect(settings["mqtt"]["broker"])
port = 1883
if keys_exists(settings["mqtt"], "port"):
conf_port = settings["mqtt"]["port"]
if isinstance(conf_port, int):
if conf_port > 0:
port = settings["mqtt"]["port"]
client.connect(settings["mqtt"]["broker"], port)
client.loop_start()
client.on_message = on_message
client.on_disconnect = on_disconnect
Expand Down
1 change: 1 addition & 0 deletions src/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"babelLocale": "de",
"mqtt": {
"broker": "",
"port": 1883,
"username": "",
"password": ""
},
Expand Down

0 comments on commit a51ba25

Please sign in to comment.