Compare commits

...
12 Commits
7 changed files with 64 additions and 16 deletions
+3
View File
@@ -15,6 +15,8 @@ Maybe this component works also with other Volvo cars. Please try out the native
Home Assistant thread can be found [here](https://community.home-assistant.io/t/volvo2mqtt-connect-your-aaos-volvo/585699). Home Assistant thread can be found [here](https://community.home-assistant.io/t/volvo2mqtt-connect-your-aaos-volvo/585699).
<b>Important note: The Volvo api currently ONLY works in these [countries](https://developer.volvocars.com/terms-and-conditions/apis-supported-locations/)</b>
If you like my work:<br> If you like my work:<br>
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/U7U8MFXCF) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/U7U8MFXCF)
@@ -34,6 +36,7 @@ If you like my work:<br>
- XC90 PHEV T8 (2024) - XC90 PHEV T8 (2024)
- XC90 B5 Mildhybrid (2024) - XC90 B5 Mildhybrid (2024)
- V90 PHEV T8 (2019)* - V90 PHEV T8 (2019)*
- V90 PHEV T6 (2024)
*only partly working *only partly working
+31
View File
@@ -1,3 +1,34 @@
## v1.8.21
### 🐛 Bug Fixes:
- Try to fix addon build #146
## v1.8.20
### 🐛 Bug Fixes:
- Fix Addon crash if icon state is `UNKOWN`
- Add `UNSPECIFIED` state for windows
## v1.8.19
### 🐛 Bug Fixes:
- Fix Estimated Charging Time not changing to zero #133
## v1.8.18
### 🐛 Bug Fixes:
- Fix Backend State Sensor returning `null`
## v1.8.17
### 🚀 Features:
- Move vehicle and vehicle details to v2 endpoint
### 🐛 Bug Fixes:
- Fix Battery Charge Level icon update
## v1.8.16 ## v1.8.16
### 🚀 Features: ### 🚀 Features:
+1 -1
View File
@@ -11,7 +11,7 @@ WORKDIR /volvoAAOS2mqtt
RUN wget --no-cache https://raw.githubusercontent.com/Dielee/volvo2mqtt/main/requirements.txt RUN wget --no-cache https://raw.githubusercontent.com/Dielee/volvo2mqtt/main/requirements.txt
# install dependencies # install dependencies
RUN pip install -r requirements.txt RUN pip install -r requirements.txt --break-system-packages
# copy the content of the local src directory to the working directory # copy the content of the local src directory to the working directory
COPY / . COPY / .
+1 -1
View File
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt" name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge" description: "Volvo AAOS MQTT bridge"
version: "1.8.16" version: "1.8.21"
slug: "volvo2mqtt" slug: "volvo2mqtt"
init: false init: false
url: "https://github.com/Dielee/volvo2mqtt" url: "https://github.com/Dielee/volvo2mqtt"
+4 -4
View File
@@ -1,10 +1,10 @@
from config import settings from config import settings
VERSION = "v1.8.16" VERSION = "v1.8.21"
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2" OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles" VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles"
VEHICLE_DETAILS_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles/{0}" VEHICLE_DETAILS_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}"
WINDOWS_STATE_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/windows" WINDOWS_STATE_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/windows"
CLIMATE_START_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/commands/climatization-start" CLIMATE_START_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/commands/climatization-start"
CLIMATE_STOP_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/commands/climatization-stop" CLIMATE_STOP_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/commands/climatization-stop"
@@ -50,7 +50,7 @@ charging_connection_states = {"CONNECTION_STATUS_DISCONNECTED": "Disconnected",
"CONNECTION_STATUS_CONNECTED_DC": "Connected DC", "CONNECTION_STATUS_CONNECTED_AC": "Connected AC", "CONNECTION_STATUS_CONNECTED_DC": "Connected DC", "CONNECTION_STATUS_CONNECTED_AC": "Connected AC",
"CONNECTION_STATUS_FAULT": "Fault"} "CONNECTION_STATUS_FAULT": "Fault"}
window_states = {"CLOSED": "OFF", "OPEN": "ON", "AJAR": "ON"} window_states = {"CLOSED": "OFF", "OPEN": "ON", "UNSPECIFIED": "UNKNOWN", "AJAR": "ON"}
door_states = {"CLOSED": "OFF", "OPEN": "ON", "UNSPECIFIED": "UNKNOWN", "AJAR": "ON"} door_states = {"CLOSED": "OFF", "OPEN": "ON", "UNSPECIFIED": "UNKNOWN", "AJAR": "ON"}
engine_states = {"RUNNING": "ON", "STOPPED": "OFF", "true": "ON", "false": "OFF"} engine_states = {"RUNNING": "ON", "STOPPED": "OFF", "true": "ON", "false": "OFF"}
+10 -3
View File
@@ -70,14 +70,14 @@ def send_car_images(vin, data, device):
if entity["id"] == "exterior_image": if entity["id"] == "exterior_image":
mqtt_client.publish( mqtt_client.publish(
url_topic, url_topic,
data["images"]["exteriorDefaultUrl"], data["images"]["exteriorImageUrl"],
retain=True retain=True
) )
if entity["id"] == "interior_image": if entity["id"] == "interior_image":
mqtt_client.publish( mqtt_client.publish(
url_topic, url_topic,
data["images"]["interiorDefaultUrl"], data["images"]["internalImageUrl"],
retain=True retain=True
) )
@@ -259,7 +259,7 @@ def update_car_data(force_update=False, overwrite={}):
else: else:
topic = f"homeassistant/{entity['domain']}/{vin}_{entity['id']}/state" topic = f"homeassistant/{entity['domain']}/{vin}_{entity['id']}/state"
if state: if state or state == 0:
mqtt_client.publish( mqtt_client.publish(
topic, topic,
json.dumps(state) if isinstance(state, dict) or isinstance(state, list) else state json.dumps(state) if isinstance(state, dict) or isinstance(state, list) else state
@@ -269,13 +269,20 @@ def update_car_data(force_update=False, overwrite={}):
def update_ha_device(entity, vin, state): def update_ha_device(entity, vin, state):
icon_config = icon_states.get(entity["id"]) icon_config = icon_states.get(entity["id"])
try:
if icon_config and state: if icon_config and state:
logging.debug("Entity " + entity["id"] + " state " + str(state))
if isinstance(state, float): if isinstance(state, float):
icon = util.get_icon_between(icon_config, state) icon = util.get_icon_between(icon_config, state)
elif state.replace(".", "").isnumeric():
state = float(state)
icon = util.get_icon_between(icon_config, state)
else: else:
icon = icon_config[state] icon = icon_config[state]
else: else:
return None return None
except:
return None
logging.debug("Updating icon to " + icon + " for " + entity["id"]) logging.debug("Updating icon to " + icon + " for " + entity["id"])
config = { config = {
+9 -2
View File
@@ -328,9 +328,16 @@ def get_backend_status():
response = session.get(API_BACKEND_STATUS, timeout=15) response = session.get(API_BACKEND_STATUS, timeout=15)
try: try:
data = response.json() data = response.json()
backend_status = data["message"] if util.keys_exists(data, "message") else "No warnings" if util.keys_exists(data, "message"):
if data["message"]:
backend_status = data["message"]
else:
backend_status = "NO_WARNING"
else:
backend_status = "NO_WARNING"
except JSONDecodeError as e: except JSONDecodeError as e:
backend_status = "No warnings" backend_status = "NO_WARNING"
return backend_status return backend_status