forked from peter/volvo2mqtt
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ef1aa528b | ||
|
|
3440dadeab | ||
|
|
1dc38e6925 | ||
|
|
81b0bb9b85 | ||
|
|
97fb95799a | ||
|
|
ab73f9afb2 | ||
|
|
285f9dc79b | ||
|
|
6dad197ed6 | ||
|
|
1ed6035a54 | ||
|
|
666eda99d0 | ||
|
|
02e64e5555 | ||
|
|
c298b8972a | ||
|
|
2c0169466c | ||
|
|
8565742752 | ||
|
|
e690f60433 | ||
|
|
9eba31804d | ||
|
|
5139d84602 | ||
|
|
2f3ca63b60 |
@@ -12,39 +12,50 @@ name: Create and publish a Docker image
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
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
|
||||
- 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
|
||||
tags: |
|
||||
type=schedule
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm/v8
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -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": "", "vccapikey": ""}' -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. Vccapi key is your api key from [here](https://developer.volvocars.com/account/). |
|
||||
| `TZ` | `string` | | Container timezone eg "Europe/Berlin" |
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@
|
||||
"volvoData": {
|
||||
"username": "",
|
||||
"password": "",
|
||||
"vin": ""
|
||||
"vin": "",
|
||||
"vccapikey": ""
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@ from const import charging_system_states, CLIMATE_START_URL, \
|
||||
|
||||
session = requests.Session()
|
||||
session.headers = {
|
||||
"vcc-api-key": "f0d0419bf51d420c8efb21cf9a127227",
|
||||
"vcc-api-key": settings["volvoData"]["vccapikey"],
|
||||
"content-type": "application/json",
|
||||
"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