Compare commits

...
6 Commits
Author SHA1 Message Date
linus d3d511477b Rework image creation 2024-10-28 07:26:02 +01:00
linus 75db5da324 Fix re-auth with OTP while app runtime #251 2024-10-27 10:06:47 +01:00
Linus DietzandGitHub fd4fc9e173 Add EX30 2024-10-27 09:43:39 +01:00
linus 75013509f4 Fix re-auth with OTP while app runtime #251 2024-10-26 18:27:29 +02:00
linus 1d8132d93a Bump version 2024-10-16 07:41:57 +02:00
linus fc529f313f Remove unused multiplier options #239 2024-10-16 07:40:37 +02:00
6 changed files with 42 additions and 35 deletions
+1
View File
@@ -21,6 +21,7 @@ If you like my work:<br>
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/U7U8MFXCF)
## Confirmed working with
- EX30 BEV (2024)
- XC40 BEV (2024)
- XC40 BEV (2023)
- XC40 BEV (2022)
+21
View File
@@ -1,3 +1,24 @@
## v1.10.5
### 🐛 Bug Fixes:
- Fix interior and exterior images if more than one car is in use
## v1.10.4
### 🐛 Bug Fixes:
- re-fix bug if app needs to be re-authenticated with OTP while runtime
## v1.10.3
### 🐛 Bug Fixes:
- Add more info logging for credential refresh process
- Fix bug if app needs to be re-authenticated with OTP while runtime
## v1.10.2
### 🐛 Bug Fixes:
- Remove unused multiplier options #239
## v1.10.1
### 🚀 Features:
+1 -4
View File
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge"
version: "1.10.1"
version: "1.10.5"
slug: "volvo2mqtt"
init: false
url: "https://github.com/Dielee/volvo2mqtt"
@@ -27,9 +27,6 @@ options:
vin: ""
vccapikey:
- null
odometerMultiplier: 1
averageSpeedDivider: 1
averageFuelConsumptionMultiplier: 1
schema:
updateInterval: int(60,)
babelLocale: str
+1 -1
View File
@@ -1,6 +1,6 @@
from config import settings
VERSION = "v1.10.1"
VERSION = "v1.10.5"
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2"
+16 -30
View File
@@ -108,37 +108,23 @@ def send_car_images(vin, data, device):
"sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "document", "Accept-Encoding": "gzip, deflate, br, zstd",
"sec-fetch-mode": "navigate", "sec-fetch-site": "none", "sec-fetch-user": "?1", "upgrade-insecure-requests": "1"}
# Post exterior image
if entity["id"] == "exterior_image":
if not os.path.exists("exterior_image.png"):
response = requests.get(data["images"]["exteriorImageUrl"], headers=headers)
if response.status_code == 200:
with open("exterior_image.png", 'wb') as image:
image.write(response.content)
# Post Images
if not os.path.exists(f'{entity["id"]}_{vin}.png'):
data_path = "exteriorImageUrl" if entity["id"] == "exterior_image" else "internalImageUrl"
response = requests.get(data["images"][data_path], headers=headers)
if response.status_code == 200:
with open(f'{entity["id"]}_{vin}.png', 'wb') as image:
image.write(response.content)
else:
logging.warning("Error getting car images: " + str(response.status_code) + " Message: " + response.text)
if os.path.exists("exterior_image.png"):
ext_image = open("exterior_image.png", mode="rb").read()
mqtt_client.publish(
image_topic,
ext_image,
retain=True
)
if entity["id"] == "interior_image":
# Post interior Image
if not os.path.exists("interior_image.png"):
response = requests.get(data["images"]["internalImageUrl"], headers=headers)
if response.status_code == 200:
with open("interior_image.png", 'wb') as image:
image.write(response.content)
if os.path.exists("interior_image.png"):
int_image = open("interior_image.png", mode="rb").read()
mqtt_client.publish(
image_topic,
int_image,
retain=True
)
if os.path.exists(f'{entity["id"]}_{vin}.png'):
ext_image = open(f'{entity["id"]}_{vin}.png', mode="rb").read()
mqtt_client.publish(
image_topic,
ext_image,
retain=True
)
def on_connect(client, userdata, flags, rc):
+2
View File
@@ -161,6 +161,7 @@ def send_otp(auth_session, data):
raise Exception ("No OTP found, exting...")
auth = auth_session.post(next_url, data=json.dumps(body))
mqtt.otp_code = None
if auth.status_code == 200:
return auth.json()
else:
@@ -198,6 +199,7 @@ def refresh_auth():
token_expires_at = datetime.now(util.TZ) + timedelta(seconds=(data["expires_in"] - 30))
refresh_token = data["refresh_token"]
else:
logging.warning("Refreshing credentials failed!: " + str(auth.status_code) + " Message: " + auth.text)
authorize(renew_tokenfile=True)