Volkswagen ID.7
Dr VW ID.7 ist ein batterieelektrisches Fahrzeug (BEV) mit semipermanenter Anbindung an die Server von Volkswagen connect.
Anbindung via MQTT
Mit einem relativ kompakten Code von Till Steinbach kann man die Fahrzeugdaten von VW connect abfragen und als MQTT-Nachricht an FHEM senden.
Python-Server
FHEM-Device
defmod ID7 MQTT2_DEVICE MQTTBridge attr ID7 autocreate 0 attr ID7 babbleName ID7 attr ID7 devStateIcon charging_car.*:ev_car@darkorange finished_car.*:ev_car@green .*_car:ev_car@black attr ID7 devicetopic weconnect attr ID7 group energyControl attr ID7 readingList MQTTBridge:weconnect/mqtt/weconnectConnected:.* connected\ MQTTBridge:weconnect/mqtt/weconnectUpdated:.* connection_updated\ MQTTBridge:weconnect/mqtt/weconnectUpdateInterval_s:.* interval\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/readiness/readinessStatus/connectionState/isOnline:.* isOnline\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/readiness/readinessStatus/connectionState/isActive:.* connection_isActive\ MQTTBridge:weconnect/mqtt/error/code:.* mqtt_error_code\ MQTTBridge:weconnect/mqtt/error/message:.* mqtt_error_message\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/controls/wakeup:.* wakeup\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/.*pictures:.* { json2nameValue($EVENT, '', $JSONMAP) }\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation:.* { json2nameValue($EVENT, '', $JSONMAP) }\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/maxChargeCurrentAC:.* charge_current\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/overallStatus:.* door_security\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/doorLockStatus:.* door_lock_status\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/doors/frontLeft/lockState:.* door_FL_ls\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/doors/frontLeft/openState:.* door_FL\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/windows/frontRight/openState:.* door_FR\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/doors/frontRight/lockState:.* door_FR_ls\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/doors/rearRight/lockState:.* door_RR_ls\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/doors/rearLeft/lockState:.* door_RL_ls\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/doors/trunk/lockState:.* trunk_ls\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/doors/trunk/openState:.* trunk\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/windows/frontLeft/openState:.* window_FL\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/windows/frontRight/openState:.* window_FR\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/windows/rearLeft/openState:.* window_RL\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/access/accessStatus/windows/rearRight/openState:.* window_RR\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/parking/parkingPosition/latitude:.* parking_latitude\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/parking/parkingPosition/longitude:.* parking_longitude\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/batteryStatus/currentSOC_pct:.* SOC\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/measurements/fuelLevelStatus/currentSOC_pct:.* SOC\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/fuelStatus/rangeStatus/primaryEngine/currentSOC_pct:.* SOC\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/targetSOC_pct:.* SOC_target\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/nextChargingTimer/targetSOCreachable:.* SOC_reachable\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/chargingProfiles/chargingProfilesStatus/nextChargingTimer/targetSOCreachable:.* SOC_reachable\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/measurements/temperatureBatteryStatus/temperatureHvBatteryMin_K:.* battery_tempMin\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/measurements/temperatureBatteryStatus/temperatureHvBatteryMax_K:.* battery_tempMax\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/batteryChargingCare/chargingCareSettings/batteryCareMode:.* battery_careMode\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/batterySupport/batterySupportStatus/batterySupport:.* battery_Support\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/batterySupport/batterySupportStatus/error/message:.* batttery_error_message\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/batterySupport/batterySupportStatus/error:.* batttery_error\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/request:.* charge_request\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/profiles/1/maxChargingCurrent:.* charge_current\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/autoUnlockPlugWhenCharged:.* charge_autoUnlock\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/autoUnlockPlugWhenChargedAC:.* charge_AC_autoUnlock\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingStatus/chargeMode:.* charge_mode\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingStatus/chargePower_kW:.* charge_power\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingStatus/chargeRate_kmph:.* charge_rate\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingStatus/chargeType:.* charge_type\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingStatus/chargingSettings:.* charge_settings\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingStatus/chargingState:.* charge_state\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingStatus/remainingChargingTimeToComplete_min:.* charge_timeremain\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/plugStatus/externalPower:.* charge_plugpower\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/plugStatus/ledColor:.* charge_plugcolor\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/plugStatus/plugConnectionState:.* charge_plugstate\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/plugStatus/plugLockState:.* charge_plugls\ \ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/measurements/rangeStatus/totalRange_km:.* range\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/measurements/rangeStatus/electricRange:.* range\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/batteryStatus/cruisingRangeElectric_km:.* range\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/fuelStatus/rangeStatus/primaryEngine/remainingRange_km:.* range\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/fuelStatus/rangeStatus/totalRange_km:.* range\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/measurements/odometerStatus/odometer:.* odometer\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/vehicleHealth.*/mileage_km:.* odometer\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/climatisationTimer/timers/1/enabled:.* timers_1_enabled\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/climatisationTimer/timers/2/enabled:.* timers_2_enabled\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/profiles/1/preferredChargingTimes/None/id:.* chargeTimer_id\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/profiles/1/preferredChargingTimes/4/enabled:.* chargeTimer_4_enabled\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/profiles/1/preferredChargingTimes/4/startTime:.* chargeTimer_4_startTime\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/profiles/1/preferredChargingTimes/4/endTime:.* chargeTimer_4_endTime\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/chargingProfiles/chargingProfilesStatus/profiles/1/preferredChargingTimes/None/id:.* chargeTimer_id\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/chargingProfiles/chargingProfilesStatus/profiles/1/preferredChargingTimes/4/enabled:.* chargeTimer_4_enabled\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/chargingProfiles/chargingProfilesStatus/profiles/1/preferredChargingTimes/4/startTime:.* chargeTimer_4_startTime\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/chargingProfiles/chargingProfilesStatus/profiles/1/preferredChargingTimes/4/endTime:.* chargeTimer_4_endTime\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/climatisationStatus/climatisationState:.* clima_state\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/windowHeatingStatus/windows/front/windowHeatingState:.* clima_window_F\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/windowHeatingStatus/windows/rear/windowHeatingState:.* clima_window_R\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/climatisationSettings/climatizationAtUnlock:.* clima_atUnlock\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/climatisationSettings/targetTemperature_C:.* clima_temperature\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisationTimers/climatisationTimersStatus/timers/1/enabled:.* timers_1_enabled\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisationTimers/climatisationTimersStatus/timers/2/enabled:.* timers_2_enabled\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/profiles/1/preferredChargingTimes/4/id:.* chargeTimer_4_id\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/chargingProfiles/chargingProfilesStatus/profiles/1/preferredChargingTimes/4/id:.* chargeTimer_4_id\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/profiles/1/preferredChargingTimes/4:.* chargeTimer_4\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/chargingProfiles/chargingProfilesStatus/profiles/1/preferredChargingTimes/4:.* chargeTimer_4\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/automation/chargingProfiles/nextChargingTimer:.* chargeTimer_next\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/chargingProfiles/chargingProfilesStatus/nextChargingTimer:.* chargeTimer_next\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/coUsers/0:.* coUsers_0\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/coUsers/0/id:.* coUsers_0_id\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/coUsers/0/role:.* coUsers_0_role\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/coUsers/0/roleReseted:.* coUsers_0_roleReseted\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/coUsers/0/enrollmentStatus:.* coUsers_0_enrollmentStatus\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/.*/webApp/status:.* status_app\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/.*/predictiveWakeUp/status:.* status_wakeup\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/.*/roadExperienceManagementLocalization/status:.* status_roadex\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/vehicleHealthInspection/maintenanceStatus/inspectionDue_days:.* maintenance_due\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/vehicleHealthInspection/maintenanceStatus/error/message:.* maintenance_eror_message\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/vehicleHealthInspection/maintenanceStatus/error:.* maintenanance_error\ \ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/request/6e1647f9-a0aa-4896-80bf-b9ec44c89e6a/status:.* 6e1647f9_status\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/request/6e1647f9-a0aa-4896-80bf-b9ec44c89e6a/operation:.* 6e1647f9_operation\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/request/6e1647f9-a0aa-4896-80bf-b9ec44c89e6a/body:.* 6e1647f9_body\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/request/6e1647f9-a0aa-4896-80bf-b9ec44c89e6a/requestId:.* 6e1647f9_charge_requestId\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/request/6e1647f9-a0aa-4896-80bf-b9ec44c89e6a/vcfRequestId:.* 6e1647f9_charge_vcfRequestId\ MQTTBridge:weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/request/6e1647f9-a0aa-4896-80bf-b9ec44c89e6a:.* 6e1647f9_else\ \ attr ID7 setList update:noArg weconnect/mqtt/weconnectForceUpdate_writetopic True\ interval:60,300 weconnect/mqtt/weconnectUpdateInterval_s_writetopic\ battery_careMode:activated,deactivated weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/batteryChargingCare/chargingCareSettings/batteryCareMode_writetopic\ clima:start,stop,on,off weconnect/vehicles/WVWxxxxxxxxxxxxxxx/controls/climatisation_writetopic\ clima_atUnlock:True,False weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/climatisationSettings/climatizationAtUnlock_writetopic\ clima_temperature:slider,20,1,25 weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/climatisationSettings/targetTemperature_C_writetopic\ clima_windowheat:True,False weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/climatisationSettings/windowHeatingEnabled_writetopic\ clima_frontleft:True,False weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/climatisationSettings/zoneFrontLeftEnabled_writetopic\ clima_frontright:True,False weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/climatisation/climatisationSettings/zoneFrontRightEnabled_writetopic\ SOC_target:slider,50,10,100 weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/targetSOC_pct_writetopic\ charge_current:maximum,reduced weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/maxChargeCurrentAC_writetopic\ charge_autoUnlock:on,off weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/autoUnlockPlugWhenCharged_writetopic\ charge_AC_autoUnlock:on,off weconnect/vehicles/WVWxxxxxxxxxxxxxxx/domains/charging/chargingSettings/autoUnlockPlugWhenChargedAC_writetopic\ attr ID7 sortby 2 attr ID7 stateFormat {my $soc=ReadingsVal("ID7","SOC",0);;\ my $ran=ReadingsVal("ID7","range",0);;\ my $cst=ReadingsVal("ID7","charge_state","");;\ my $ret;;\ if( $cst eq "charging"){\ $ret=sprintf("<p align=\"left\">\n%s_car\n<br/>%d %% (%d km)",$cst,$soc,$ran);;\ my $cp=ReadingsVal("ID7","charge_power",0);;\ my $tr=ReadingsVal("ID7","charge_timeremain",0);;\ $ret.=sprintf("\n<br>charging %.1f kW, %d min",$cp,$tr)\ }elsif( $cst eq "notReadyForCharging" ){\ $ret=sprintf("<p align=\"left\">\n%s_car\n<br/>%d %% (%d km)",$cst,$soc,$ran);;\ }elsif( $cst eq "chargePurposeReachedAndNotConservationCharging"){\ $ret=sprintf("<p align=\"left\">\nfinished_car\n<br/>%d %% (%d km)",$soc,$ran);;\ my $ce=ReadingsVal("Wally","energy_today",0);;\ $ret.=sprintf("\n<br>acquired %.1f kWh",$ce)\ }\ $ret.="\n</p>";;\ return $ret;;\ } attr ID7 userReadings message:SOC.* {my $soc=ReadingsVal("ID7","SOC",0);;\ my $ran=ReadingsVal("ID7","range",0);;\ my $cst=ReadingsVal("ID7","charge_state","");;\ my $ret=sprintf("Der ID7 hat %d %% Batterieladung, das reicht für %d Kilometer",$soc,$ran);;\ if( $cst eq "charging"){\ my $cp=ReadingsVal("ID7","charge_power",0);;\ my $tr=ReadingsVal("ID7","charge_timeremain",0);;\ $ret.=sprintf(", geladen wird noch %d Minuten mit %.1f Kilowatt.",$tr,$cp)\ }\ return $ret;;\ },\ parking_location:parking_latitude.* {my $lat=ReadingsVal("ID7","parking_latitude",0);;\ my $lon=ReadingsVal("ID7","parking_longitude",0);;\ return ((sqrt(($lon-0.00)**2+($lat-0.00)**2)<=0.01)?"Home":"unknown")\ }