Compare commits

...
7 Commits
Author SHA1 Message Date
Linus Dietz 4d8b5e5006 Optimize lock/unlock behaviour 2023-06-24 19:47:02 +02:00
Linus Dietz e8315ba0fd Merge remote-tracking branch 'origin/main' into main 2023-06-24 18:08:09 +02:00
Linus Dietz 4fca54b19f Add broker port to ha addon conf 2023-06-24 18:07:59 +02:00
Linus DietzandGitHub a411a1a59d Add broker Port 2023-06-24 18:06:15 +02:00
Linus Dietz a51ba25061 Add mqtt broker port option 2023-06-24 18:02:56 +02:00
Linus Dietz 1d37b3aca7 Revert "Bump version"
This reverts commit 1574fa96
2023-06-24 17:54:09 +02:00
Linus Dietz 1574fa968c Bump version 2023-06-24 17:53:12 +02:00
6 changed files with 29 additions and 10 deletions
+2 -2
View File
@@ -41,7 +41,7 @@ NOTE: Energy status currently available only for cars in the Europe / Middle Eas
Just install this addon with the following command.
Please note to fill in your settings inside the environment variables.
`docker run -d --pull=always -e CONF_updateInterval=300 -e CONF_babelLocale='de' -e CONF_mqtt='@json {"broker": "", "username": "", "password": ""}' -e CONF_volvoData='@json {"username": "", "password": "", "vin": "", "vccapikey": "", "odometerMultiplier": 1}' -e TZ='Europe/Berlin' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:latest`
`docker run -d --pull=always -e CONF_updateInterval=300 -e CONF_babelLocale='de' -e CONF_mqtt='@json {"broker": "", "username": "", "password": "", "port": 1883}' -e CONF_volvoData='@json {"username": "", "password": "", "vin": "", "vccapikey": "", "odometerMultiplier": 1}' -e TZ='Europe/Berlin' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:latest`
<b>HA Add-On:</b><br>
@@ -53,7 +53,7 @@ Here is what every option means:
| -------------------- | :-------: | :----------: | --------------------------------------------------------------- |
| `CONF_updateInterval` | `int` | **required** | Update intervall in seconds. |
| `CONF_babelLocale` | `string` | **required** | Select your country from this [list](https://www.ibm.com/docs/en/radfws/9.7?topic=overview-locales-code-pages-supported). "Locale name" is the column you need! |
| `CONF_mqtt` | `json` | **required** | Broker = Mqtt Broker IP / Username and Passwort are optional! |
| `CONF_mqtt` | `json` | **required** | Broker = Mqtt Broker IP / Username and Passwort are optional! Broker port can be changed. If no value is given, port 1883 will be used. |
| `CONF_volvoData` | `json` | **required** | Username and password are REQUIRED. Car vin can be a single vin or a list of multiple vins like `["vin1", "vin2"]`. If no vin is provided, <b>ALL</b> of your vehicles will be used. Vccapi key is REQUIRED. Get your Vccapi key from [here](https://developer.volvocars.com/account/). Odometer Multiplier is sometimes 10, sometimes 1. Try what's right for your car. If you leave it empty, the multiplier will be 1. |
| `CONF_debug` | `string` | | Debug option (true/false) - optional! |
| `TZ` | `string` | | Container timezone eg "Europe/Berlin" |
+3 -1
View File
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge"
version: "1.4.0"
version: "1.4.2"
slug: "volvo2mqtt"
init: false
url: "https://github.com/Dielee/volvo2mqtt"
@@ -11,6 +11,7 @@ options:
debug: false
mqtt:
broker: null
port: 1883
username: ""
password: ""
volvoData:
@@ -25,6 +26,7 @@ schema:
debug: bool
mqtt:
broker: str
port: int(1,)
username: str?
password: str?
volvoData:
+1 -1
View File
@@ -1,6 +1,6 @@
from config import settings
VERSION = "v1.4.0"
VERSION = "v1.4.2"
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
+21 -5
View File
@@ -2,6 +2,7 @@ import time
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
@@ -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
@@ -70,10 +77,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)
update_car_data(True, {"entity_id": "lock_status", "state": "LOCKED"})
elif payload == "UNLOCK":
volvo.api_call(CAR_UNLOCK_URL, "POST", vin)
update_car_data(True)
update_car_data(True, {"entity_id": "lock_status", "state": "UNLOCKED"})
elif "update_data" in msg.topic:
if payload == "PRESS":
update_car_data(True)
@@ -88,7 +95,7 @@ def update_loop():
time.sleep(settings["updateInterval"])
def update_car_data(force_update=False):
def update_car_data(force_update=False, overwrite={}):
global last_data_update
last_data_update = format_datetime(datetime.now(), format="medium", locale=settings["babelLocale"])
for vin in volvo.vins:
@@ -96,12 +103,21 @@ def update_car_data(force_update=False):
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:
state = volvo.api_call(entity["url"], "GET", vin, entity["id"], force_update)
if entity["id"] == ov_entity_id:
state = ov_state
else:
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"
+1
View File
@@ -3,6 +3,7 @@
"babelLocale": "de",
"mqtt": {
"broker": "",
"port": 1883,
"username": "",
"password": ""
},
+1 -1
View File
@@ -10,7 +10,7 @@ configuration:
description: Enable Volvo API debug, normaly this can stay off
mqtt:
name: MQTT Broker settings
description: Broker is your mqtt broker IP eg "192.168.0.1". Mqtt username and password are optional.
description: Broker is your mqtt broker IP eg "192.168.0.1". Mqtt username and password are optional. Broker port can be changed. If no value is given, port 1883 will be used.
volvoData:
name: Volvo APP credentials
description: You have to enter your Volvo app credentials. The username is normally your email, and the password is the password you use for your Volvo app. The vin can stay empty. The Add-On will use any vin inside your Volvo account. VCCAPI key is required and comes from your Volvo developer account. Odometer multiplier is sometimes 10, sometimes 1. Leave it empty if you don't know what's right. Take a look at the GitHub repo for more information!