Also... ich hab auch ein bisschen mit Skodaconnect experimentiert. Mein aktueller Stand:
Separater Raspberry, da Python3 benötigt - den Python auf der openWB hab ich mir noch nicht getraut, upzudaten.
Dann das Skodaconnect von Github installieren: python3 -m pip install skodaconnect
Über die Konsole kann ich dann ein Python-Script aufrufen, welches mir zurückgibt:
stefan@ubuntu:/usr/sbin$ python3 skodaconnect_min.py
Content-Type: text/plain
83
Wobei die 83 der SoC ist.
Eigentlich war der Plan, das ausführbare Script über den Brower aufrufen zu können, den HTTP-Aufruf dann in der openWB als SoC-Abrufadresse anzugeben, aber das hab ich leider nicht hinbekommen.
Vielleicht hat ja noch jemand Lust und mehr Ahnung, um sich dem Thema mal anzunehmen?
Schöne Grüße...
Stefan
P.S.: Script kann ich gerne mal hier angeben - Username und Passwort sind entsprechend einzusetzen:
Code: Alles auswählen
#!/usr/bin/env python3
import pprint
import asyncio
import logging
import inspect
import time
import sys
import os
from aiohttp import ClientSession
from datetime import datetime
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
try:
from skodaconnect import Connection
except ModuleNotFoundError:
print("Unable to import library")
sys.exit(1)
logging.basicConfig(level=logging.ERROR)
USERNAME = 'xxxxxxxxxxxxxxxxxxxxxxxx'
PASSWORD = 'xxxxxxxxxxx'
PRINTRESPONSE = True
COMPONENTS = {
'sensor': 'sensor',
'binary_sensor': 'binary_sensor',
'lock': 'lock',
'device_tracker': 'device_tracker',
'switch': 'switch',
}
RESOURCES = [
"adblue_level",
"auxiliary_climatisation",
"battery_level",
"charge_max_ampere",
"charger_action_status",
"charging",
"charge_rate",
"charging_power",
"charging_cable_connected",
"charging_cable_locked",
"charging_time_left",
"climater_action_status",
"climatisation_target_temperature",
"climatisation_without_external_power",
"combined_range",
"combustion_range",
"departure1",
"departure2",
"departure3",
"distance",
"door_closed_left_back",
"door_closed_left_front",
"door_closed_right_back",
"door_closed_right_front",
"door_locked",
"electric_climatisation",
"electric_range",
"energy_flow",
"external_power",
"fuel_level",
"hood_closed",
"last_connected",
"lock_action_status",
"oil_inspection",
"oil_inspection_distance",
"outside_temperature",
"parking_light",
"parking_time",
"pheater_heating",
"pheater_status",
"pheater_ventilation",
"position",
"refresh_action_status",
"refresh_data",
"request_in_progress",
"request_results",
"requests_remaining",
"service_inspection",
"service_inspection_distance",
"sunroof_closed",
"trip_last_average_auxillary_consumption",
"trip_last_average_electric_consumption",
"trip_last_average_fuel_consumption",
"trip_last_average_speed",
"trip_last_duration",
"trip_last_entry",
"trip_last_length",
"trip_last_recuperation",
"trip_last_total_electric_consumption",
"trunk_closed",
"trunk_locked",
"vehicle_moving",
"window_closed_left_back",
"window_closed_left_front",
"window_closed_right_back",
"window_closed_right_front",
"window_heater",
"windows_closed"
]
def is_enabled(attr):
"""Return true if the user has enabled the resource."""
return attr in RESOURCES
async def main():
"""Main method."""
async with ClientSession(headers={'Connection': 'keep-alive'}) as session:
connection = Connection(session, USERNAME, PASSWORD, PRINTRESPONSE)
if await connection.doLogin():
instruments = set()
for vehicle in connection.vehicles:
dashboard = vehicle.dashboard(mutable=True)
for instrument in (
instrument
for instrument in dashboard.instruments
if instrument.component in COMPONENTS
and is_enabled(instrument.slug_attr)):
instruments.add(instrument)
else:
return False
# Output all instruments and states
print ('Content-Type: text/plain')
print ('')
for instrument in instruments:
if "battery_level" in instrument.attr :
print (str(instrument.state))
#print(f'{instrument.full_name} - ({instrument.attr})')
#print(f'\tstr_state: {instrument.str_state} - state: {}')
#print(f'\tattributes: {instrument.attributes}')
#print("")
# Examples for using set functions:
#vehicle.set_refresh() # Takes no arguments, will trigger forced update
#vehicle.set_charger(action = "start") # action = "start" or "stop"
#vehicle.set_charger_current(value) # value = 1 <=> 255 (PHEV: 252 for reduced and 254 for max)
#vehicle.set_battery_climatisation(mode = False) # mode = False or True
#vehicle.set_climatisation(mode = "auxilliary", spin="1234") # mode = "auxilliary", "electric" or "off". spin is S-PIN and only needed for aux heating
#vehicle.set_climatisation_temp(temperature = 22) # temperature = integer from 16 to 30
#vehicle.set_window_heating(action = "start") # action = "start" or "stop"
#vehicle.set_lock(action = "unlock", spin = "1234") # action = "unlock" or "lock". spin = SPIN, needed for both
#vehicle.set_pheater(mode = "heating", spin = "1234") # action = "heating", "ventilation" or "off". spin = SPIN, not needed for off
#vehicle.set_charge_limit(limit = 30) # limit = 0,10,20,30,40,50
#vehicle.set_timer_active(id = 1, action = "on"} # id = 1, 2, 3, action = "on" or "off".
#vehicle.set_timer_schedule(id = 1, # id = 1, 2, 3
# schedule = { # Set the departure time, date and periodicity
# "enabled": True, # Set the timer active or not, True or False
# "recurring": True, # True or False for recurring
# "date": "2021-05-21", # Date for departure, not needed for recurring
# "time": "08:00", # Time for departure, always needed
# "days": "nyynnnn" # Days (mon-sun) for recurring schedule, n=disable, y=enable
# })
# Example using a set function
#if await vehicle.set_charge_limit(limit=40):
# print("Request completed successfully.")
#else:
# print("Request failed.")
#print(vehicle.timer_action_status)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())