DaheimLaden Wallbox mitttels ModBus TCP abfragen

Begonnen von Blowfly, 23 Mai 2023, 00:56:24

Vorheriges Thema - Nächstes Thema

Blowfly

Hallo,

nachdem inzwischen eine Modbus-fähige Firmware für die DaheimLaden Wallbox rausgekommen ist, habe ich dafür ein ModbusAttr Device erstellt, dessen Konfiguration ich teilen möchte, falls da jemand auch Bedarf hat. Die Parameter muss man sicher nicht alle immer abfragen (Station-ID z.B. wird sich nicht oft ändern..), d.h. es können auch gerne Parameter gelöscht werden. Ich frage alle 114 Words auf einmal ab, das klappt bisher einwandfrei. Meine Box ist aber auch per LAN-Kabel angeschlossen, insbesondere über WLAN scheint es da öfter mal Probleme zu geben oder gegeben zu haben.

Die Modbusfähige Firmware (DaheimLader Smart: Version ab 3.12DA, DaheimLader Touch ab 1.12) muss ggf. auf Anfrage beim normalerweise sehr flotten und freundlichen Service aufgespielt werden. Hier der Link zur aktuellen Daheimladen Modbus Doku (PDF). Falls er nicht mehr funktioniert, findet man die neueste Version auf der Homepage.

Hinweis: Beim wiederholten Starten und Stoppen des Ladevorgangs über Modbus soll der Lademodus auf "Plug and Charge" stehen, siehe auch die Doku für Register 93. Ich lade aber normalerweise mit Hilfe von evcc mit PV-Überschuss, da funktioniert auch der "RFID/Modbus-OCPP"-Modus.

Ergänzungen und Verbesserungsvorschläge sind natürlich immer willkommen.

Viele Grüße,
Hans

define myWallbox ModbusAttr 255 30 IP-DER-WALLBOX:502 TCP
attr myWallbox dev-h-combine 114
attr myWallbox dev-h-defPoll 1
attr myWallbox dev-h-write 16
attr myWallbox dev-type-uint16be-len 1
attr myWallbox dev-type-uint16be-unpack S>
attr myWallbox dev-type-uint16be_CV-expr $val *0.1
attr myWallbox dev-type-uint16be_CV-len 1
attr myWallbox dev-type-uint16be_CV-unpack S>
attr myWallbox dev-type-uint16be_Str-len 16
attr myWallbox dev-type-uint16be_Str-unpack A*
attr myWallbox dev-type-uint32be-len 2
attr myWallbox dev-type-uint32be-unpack N
attr myWallbox dev-type-uint32be_kWh-expr $val * 0.1
attr myWallbox dev-type-uint32be_kWh-len 2
attr myWallbox dev-type-uint32be_kWh-unpack N
attr myWallbox event-on-change-reading .*
attr myWallbox obj-h00000-map 1:Standby, 2:Connected, 3:Start, 4:Charging, 5:Start_fail, 6:Charging_end, 7:Charger_system_fail, 8:Appointment, 9:Firmware_Upgrade, 10:Power_on
attr myWallbox obj-h00000-reading Wallbox_Status
attr myWallbox obj-h00000-type uint16be
attr myWallbox obj-h00002-map 0:EV_Not_Connected, 1:EV_Connected
attr myWallbox obj-h00002-reading Connection_Status
attr myWallbox obj-h00002-type uint16be
attr myWallbox obj-h00004-map 0:No_Fault, 11:CP-Voltage-Fault, 12:Emergency-Stop, 13:Under_Voltage, 14:Over_Voltage, 15:Over_temperature, 16:Meter_Fault, 17:Leakage_Fault, 18:Output_Short, 19:Over_Current,21:Vehicle_Communication_Fault, 22:Vehicle_Unrecognizable, 23:Relay_Adhesion, 24:Leakage_Device_Fault, 25:PE_Fault, 26:Start_Charging_Fault
attr myWallbox obj-h00004-reading Error_code
attr myWallbox obj-h00004-type uint16be
attr myWallbox obj-h00006-reading L1_Charging_Current
attr myWallbox obj-h00006-type uint16be_CV
attr myWallbox obj-h00008-reading L2_Charging_Current
attr myWallbox obj-h00008-type uint16be_CV
attr myWallbox obj-h00010-reading L3_Charging_Current
attr myWallbox obj-h00010-type uint16be_CV
attr myWallbox obj-h00012-reading Active_Power
attr myWallbox obj-h00012-type uint32be
attr myWallbox obj-h00016-reading L1_Active_Power
attr myWallbox obj-h00016-type uint32be
attr myWallbox obj-h00020-reading L2_Active_Power
attr myWallbox obj-h00020-type uint32be
attr myWallbox obj-h00024-reading L3_Active_Power
attr myWallbox obj-h00024-type uint32be
attr myWallbox obj-h00028-reading Energy_Meter
attr myWallbox obj-h00028-type uint32be_kWh
attr myWallbox obj-h00032-reading EVSE_max_current
attr myWallbox obj-h00032-type uint16be_CV
attr myWallbox obj-h00034-reading EVSE_min_current
attr myWallbox obj-h00034-type uint16be_CV
attr myWallbox obj-h00036-reading Cable_max_current
attr myWallbox obj-h00036-setexpr $val*10
attr myWallbox obj-h00036-type uint16be_CV
attr myWallbox obj-h00038-reading Station_ID
attr myWallbox obj-h00038-type uint16be_Str
attr myWallbox obj-h00054-reading Card_ID
attr myWallbox obj-h00054-type uint16be_Str
attr myWallbox obj-h00072-reading Charged_energy
attr myWallbox obj-h00072-type uint16be_CV
attr myWallbox obj-h00074-reading Start_Charging_time_hh
attr myWallbox obj-h00074-type uint16be
attr myWallbox obj-h00075-reading Start_Charging_time_mm
attr myWallbox obj-h00075-type uint16be
attr myWallbox obj-h00076-reading Start_Charging_time_ss
attr myWallbox obj-h00076-type uint16be
attr myWallbox obj-h00078-reading Charging_time
attr myWallbox obj-h00078-type uint32be
attr myWallbox obj-h00082-reading End_Charging_time_hh
attr myWallbox obj-h00082-type uint16be
attr myWallbox obj-h00083-reading End_Charging_time_mm
attr myWallbox obj-h00083-type uint16be
attr myWallbox obj-h00084-reading End_Charging_time_ss
attr myWallbox obj-h00084-type uint16be
attr myWallbox obj-h00087-reading Safe_current
attr myWallbox obj-h00087-set 1
attr myWallbox obj-h00087-setexpr $val*10
attr myWallbox obj-h00087-type uint16be_CV
attr myWallbox obj-h00089-reading Conn_timeout
attr myWallbox obj-h00089-set 1
attr myWallbox obj-h00089-type uint16be
attr myWallbox obj-h00091-reading Limit_charging_current
attr myWallbox obj-h00091-set 1
attr myWallbox obj-h00091-setexpr $val*10
attr myWallbox obj-h00091-type uint16be_CV
attr myWallbox obj-h00093-map 0:Plug&Charge, 1:RFID/OCPP_start+stop, 2:Charger_locked
attr myWallbox obj-h00093-reading Charge_control
attr myWallbox obj-h00093-set 1
attr myWallbox obj-h00093-type uint16be
attr myWallbox obj-h00095-map 0:Idle, 1:Start_charging, 2:Stop_charging
attr myWallbox obj-h00095-reading Charge_command
attr myWallbox obj-h00095-set 1
attr myWallbox obj-h00095-type uint16be
attr myWallbox obj-h00097-reading Real_time_YY
attr myWallbox obj-h00097-set 1
attr myWallbox obj-h00097-type uint16be
attr myWallbox obj-h00098-reading Real_time_MM
attr myWallbox obj-h00098-set 1
attr myWallbox obj-h00098-type uint16be
attr myWallbox obj-h00099-reading Real_time_DD
attr myWallbox obj-h00099-set 1
attr myWallbox obj-h00099-type uint16be
attr myWallbox obj-h00100-reading Real_time_hh
attr myWallbox obj-h00100-set 1
attr myWallbox obj-h00100-type uint16be
attr myWallbox obj-h00101-reading Real_time_mm
attr myWallbox obj-h00101-set 1
attr myWallbox obj-h00101-type uint16be
attr myWallbox obj-h00102-reading Real_time_ss
attr myWallbox obj-h00102-set 1
attr myWallbox obj-h00102-type uint16be
attr myWallbox obj-h00109-reading L1_real-time_Voltage
attr myWallbox obj-h00109-type uint16be_CV
attr myWallbox obj-h00111-reading L2_real-time_Voltage
attr myWallbox obj-h00111-type uint16be_CV
attr myWallbox obj-h00113-reading L3_real-time_Voltage
attr myWallbox obj-h00113-type uint16be_CV
attr myWallbox room Garage
attr myWallbox stateFormat {my $WBStatus=ReadingsVal($name,"Wallbox_Status", "?");;\
 my $WBControl="Charge Mode: ".ReadingsVal($name, "Charge_control","").".<br>";;\
    if    ($WBStatus eq "Standby") {return $WBControl."Wallbox in Standby and not connected to vehicle." }\
    elsif ($WBStatus eq "Connected") {return $WBControl."Connected to vehicle."  }\
    elsif ($WBStatus eq "Start") {return $WBControl."Start of charging..."}\
    elsif ($WBStatus eq "Charging") {ReadingsTimestamp($name,"Start_Charging_Time","") =~ /^(\d+)-(\d+)-(\d+)\s(\d+:\d+:\d+)$/;; \
           return $WBControl."<span style=\"color:#FFFF00\">Charging started at $3.$2.$1, $4, current power: "\
           .ReadingsNum($name, "Active_Power",42)." W, charged energy: "\
           .ReadingsNum($name, "Charged_energy",88)." kWh in ".ReadingsNum($name, "Charging_time",77)\
           ." s (average ".sprintf("%0.3f",3600*ReadingsNum($name, "Charged_energy",11)/ReadingsNum($name, "Charging_time",11))\
           ." kW)</span>"}\
    elsif ($WBStatus eq "Start_fail") \
           {return $WBControl."<span style=\"color:#00FF00\">Error during start of charging (vehicle offline or cable removed).</span>"}\
    elsif ($WBStatus eq "Charging_end") {ReadingsTimestamp($name,"End_Charging_Time","") =~ /^(\d+)-(\d+)-(\d+)\s(\d+:\d+:\d+)$/;; \
           return $WBControl.'<span style="color:#00FF80">Charging ended at '."$3.$2.$1, $4, charged energy: "\
           .ReadingsNum($name, "Charged_energy",11)." kWh in ".ReadingsNum($name, "Charging_time",99)." s (average power "\
           .sprintf("%0.3f",3600*ReadingsNum($name, "Charged_energy",11)/ReadingsNum($name, "Charging_time",11))." kW)</span>"}\
    elsif ($WBStatus eq "Charger_system_fail") {return $WBControl.'<span style="color:#FF0000">Charger system failure, error code '\
           .ReadingsVal($name, "Error_code","").".</span>"}\
    elsif ($WBStatus eq "Appointment") {return  $WBControl."Wallbox Control via OCPP"}\
    elsif ($WBStatus eq "Firmware_Upgrade") {return $WBControl."Firmware upgrade running..."}\
    elsif ($WBStatus eq "Power_on") {return $WBControl."Powering on..."}\
    else {return $WBControl."Undefined state!"}\
}
attr myWallbox userReadings Real_Time:Real.* { sprintf ("%02d.%02d.%0000d %02d:%02d:%02d",\
   ReadingsVal($name,"Real_time_DD","01"),\
   ReadingsVal($name,"Real_time_MM","01"), \
   ReadingsVal($name, "Real_time_YY","2023"), \
   ReadingsVal($name, "Real_time_hh","01"), \
   ReadingsVal($name, "Real_time_mm","01"), \
   ReadingsVal($name, "Real_time_ss","01"))\
   },\
End_Charging_Time:End_Charging.* {sprintf ("%02d:%02d:%02d",\
   ReadingsVal($name, "End_Charging_time_hh","01"), \
   ReadingsVal($name, "End_Charging_time_mm","01"), \
   ReadingsVal($name, "End_Charging_time_ss","01"))\
   },\
Start_Charging_Time:Start_Charging.* {sprintf ("%02d:%02d:%02d",\
   ReadingsVal($name, "Start_Charging_time_hh","01"), \
   ReadingsVal($name, "Start_Charging_time_mm","01"), \
   ReadingsVal($name, "Start_Charging_time_ss","01"))\
   }\
FHEM 6.2 auf RaspBerry Pi 2 B; SDuino für IT Steckdosen und Livolo-Schalter; Jeelink für LaCrosse T&H Sensoren; OWServer mit DS18B20 T-Sensoren; ZigBee mit deCONZ (RaspBee), Alexa, Homekit