mirror of
https://github.com/Dielee/volvo2mqtt.git
synced 2026-07-22 02:13:01 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c0169466c | ||
|
|
8565742752 | ||
|
|
e690f60433 | ||
|
|
9eba31804d | ||
|
|
5139d84602 | ||
|
|
2f3ca63b60 |
@@ -19,28 +19,31 @@ env:
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: 'arm64,arm'
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||
with:
|
||||
|
||||
@@ -1,2 +1,21 @@
|
||||
# volvo2mqtt
|
||||
Home Assistant addon for connecting AAOS Volvos
|
||||
# Volvo2Mqtt
|
||||
|
||||
This component establishes a connection between the newer AAOS Volvo cars and Home Assistant via MQTT.<br>
|
||||
Maybe this component works also with other Volvo cars. Please try out the native Volvo [integration](https://www.home-assistant.io/integrations/volvooncall/) before using this component! If the native component doesn't work for your car, try this mqtt bridge.
|
||||
|
||||
## Setup
|
||||
|
||||
Just install this addon with the following command.
|
||||
Please note to fill in your settings inside the environment variables.
|
||||
|
||||
`docker run -e CONF_updateInterval=300 -e CONF_babelLocale='de' -e CONF_mqtt='@json {"broker": "", "username": "", "password": ""}' -e CONF_volvoData='@json {"username": "", "password": "", "vin": ""}' -e TZ='Europe/Berlin' --name volvo2mqtt ghcr.io/dielee/volvo2mqtt:main`
|
||||
|
||||
Here is what every option means:
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| -------------------- | :-------: | :----------: | --------------------------------------------------------------- |
|
||||
| `updateInterval` | `int` | **required** | Updateintervall in seconds. |
|
||||
| `babelLocale` | `string` | **required** | Locale for date Format |
|
||||
| `mqtt` | `json` | **required** | Broker = Mqtt Broker IP / Username and Passwort are optional! |
|
||||
| `volvoData` | `json` | **required** | Username and password are required. Car vin is optional. If no vin is provided, the system will always use the first vehicle in API. |
|
||||
| `TZ` | `string` | | Container timezone eg "Europe/Berlin" |
|
||||
|
||||
@@ -13,7 +13,7 @@ session.headers = {
|
||||
"accept": "*/*"
|
||||
}
|
||||
|
||||
token_expires_at = None
|
||||
token_expires_at: datetime
|
||||
refresh_token = None
|
||||
vin = ""
|
||||
recharge_response = {}
|
||||
@@ -145,23 +145,38 @@ def api_call(url, method, sensor_id=None):
|
||||
if url == VEHICLE_DETAILS_URL:
|
||||
return data["data"]
|
||||
elif sensor_id == "battery_charge_level":
|
||||
return data["data"]["batteryChargeLevel"]["value"]
|
||||
elif sensor_id == "electric_range":
|
||||
return data["data"]["electricRange"]["value"]
|
||||
elif sensor_id == "charging_system_status":
|
||||
return charging_system_states[data["data"]["chargingSystemStatus"]["value"]]
|
||||
elif sensor_id == "estimated_charging_time":
|
||||
charging_system_state = charging_system_states[data["data"]["chargingSystemStatus"]["value"]]
|
||||
if charging_system_state == "Charging":
|
||||
return data["data"]["estimatedChargingTime"]["value"]
|
||||
if "batteryChargeLevel" in data["data"]:
|
||||
return data["data"]["batteryChargeLevel"]["value"]
|
||||
else:
|
||||
return 0
|
||||
return ""
|
||||
elif sensor_id == "electric_range":
|
||||
if "electricRange" in data["data"]:
|
||||
return data["data"]["electricRange"]["value"]
|
||||
else:
|
||||
return ""
|
||||
elif sensor_id == "charging_system_status":
|
||||
if "charging_system_status" in data["data"]:
|
||||
return charging_system_states[data["data"]["chargingSystemStatus"]["value"]]
|
||||
else:
|
||||
return ""
|
||||
elif sensor_id == "estimated_charging_time":
|
||||
if "chargingSystemStatus" in data["data"]:
|
||||
charging_system_state = charging_system_states[data["data"]["chargingSystemStatus"]["value"]]
|
||||
if charging_system_state == "Charging":
|
||||
return data["data"]["estimatedChargingTime"]["value"]
|
||||
else:
|
||||
return 0
|
||||
else:
|
||||
return ""
|
||||
elif sensor_id == "estimated_charging_finish_time":
|
||||
charging_system_state = charging_system_states[data["data"]["chargingSystemStatus"]["value"]]
|
||||
if charging_system_state == "Charging":
|
||||
charging_time = int(data["data"]["estimatedChargingTime"]["value"])
|
||||
charging_finished = datetime.now() + timedelta(minutes=charging_time)
|
||||
return format_datetime(charging_finished, format="medium", locale=settings["babelLocale"])
|
||||
if "chargingSystemStatus" in data["data"]:
|
||||
charging_system_state = charging_system_states[data["data"]["chargingSystemStatus"]["value"]]
|
||||
if charging_system_state == "Charging":
|
||||
charging_time = int(data["data"]["estimatedChargingTime"]["value"])
|
||||
charging_finished = datetime.now() + timedelta(minutes=charging_time)
|
||||
return format_datetime(charging_finished, format="medium", locale=settings["babelLocale"])
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
elif sensor_id == "lock_status":
|
||||
|
||||
Reference in New Issue
Block a user