fix: read PSA DPF values big-endian, add fuel level candidates
Validate YAML Configs / Validate YAML Schema (push) Successful in 10s

OBDb marks D52F/D519/D525/D530 as little-endian, which showed 425 %
soot and 1632 km since regeneration next to 0.32 g/L soot load.
Big-endian gives 1.7 % and 6.4 km, consistent with the soot load.

The ECU does not answer 01 2F, so add OBDb's three PSA fuel level
sources on the engine ECU (22 0227, 22 040F, 21 A8).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Piotr TrzcinskiandClaude Opus 5.5 committed 2026-10-11 12:05:30 +02:00
1 parent 36a505b0e5
commit fb97346806
2 files changed
+94 -9

No files matched your search

+47 -5
View File
@@ -40,6 +40,7 @@ devices:
- { key: ambient_temp, preset: ambient_temp, update_interval: 60s }
- { key: battery, preset: battery_voltage, update_interval: 10s }
- { key: run_time, preset: run_time, update_interval: 10s }
# The ECU does not answer 01 2F; see the psa_fuel_level_* candidates below.
- key: fuel_level
preset: fuel_level
update_interval: 30s
@@ -184,12 +185,13 @@ devices:
# ── PSA engine ECU (Bosch MD1CS003, 1.5 BlueHDi), UDS mode 22 ──
# DIDs and scaling from OBDb (github.com/OBDb/Citroen, header 6A8 → 688).
# Names match what Car Scanner's "Citroen 1.5 BlueHDI" profile shows.
# Byte a is the first byte after the "62 Dxxx" echo.
# Byte a is the first byte after the "62 Dxxx" echo. OBDb marks some of these DIDs as
# little-endian (blsb), but on this ECU that gave 425 % soot, so all values are read big-endian.
- key: psa_dpf_soot_level
mode: "22"
pid: "D52F"
pre_commands: ["ATSH6A8", "ATCRA688"]
formula: "(b*256+a)/10.24"
formula: "(a*256+b)/10.24"
unit: "%"
state_class: measurement
accuracy_decimals: 0
@@ -217,7 +219,7 @@ devices:
mode: "22"
pid: "D519"
pre_commands: ["ATSH6A8", "ATCRA688"]
formula: "(b*256+a)/16"
formula: "(a*256+b)/16"
unit: "km"
device_class: distance
state_class: measurement
@@ -227,7 +229,7 @@ devices:
mode: "22"
pid: "D525"
pre_commands: ["ATSH6A8", "ATCRA688"]
formula: "(b*256+a)/16"
formula: "(a*256+b)/16"
unit: "km"
device_class: distance
state_class: measurement
@@ -237,7 +239,7 @@ devices:
mode: "22"
pid: "D530"
pre_commands: ["ATSH6A8", "ATCRA688"]
formula: "(b*256+a-floor(b/128)*65536)*16"
formula: "(a*256+b-floor(a/128)*65536)*16"
unit: "km"
device_class: distance
state_class: measurement
@@ -442,3 +444,43 @@ devices:
accuracy_decimals: 0
entity_category: diagnostic
update_interval: 3600s
# ── PSA fuel level candidates (engine ECU 7E0 → 7E8, OBDb) ──
# OBDb lists three sources; keep whichever answers on this car and disable the rest.
- key: psa_fuel_level_pct
mode: "22"
pid: "0227"
pre_commands: ["ATSH7E0", "ATCRA"]
formula: "a*100/255"
unit: "%"
state_class: measurement
accuracy_decimals: 0
icon: mdi:gas-station
update_interval: 60s
publish:
deadband: 0.5
min_interval: 60s
- key: psa_fuel_level_l
mode: "22"
pid: "040F"
pre_commands: ["ATSH7E0", "ATCRA"]
formula: "(a*256+b-floor(a/128)*65536)*711/1250"
unit: "L"
device_class: volume_storage
state_class: measurement
accuracy_decimals: 1
icon: mdi:gas-station
update_interval: 60s
publish:
deadband: 0.3
min_interval: 60s
- key: psa_fuel_level_21
mode: "21"
pid: "A8"
pre_commands: ["ATSH7E0", "ATCRA"]
formula: "(m*256+n)/256"
unit: "%"
state_class: measurement
accuracy_decimals: 0
icon: mdi:gas-station
update_interval: 60s
+47 -4
View File
@@ -184,7 +184,7 @@ templates:
pre_commands:
- ATSH6A8
- ATCRA688
formula: (b*256+a)/10.24
formula: (a*256+b)/10.24
unit: '%'
state_class: measurement
accuracy_decimals: 0
@@ -218,7 +218,7 @@ templates:
pre_commands:
- ATSH6A8
- ATCRA688
formula: (b*256+a)/16
formula: (a*256+b)/16
unit: km
device_class: distance
state_class: measurement
@@ -230,7 +230,7 @@ templates:
pre_commands:
- ATSH6A8
- ATCRA688
formula: (b*256+a)/16
formula: (a*256+b)/16
unit: km
device_class: distance
state_class: measurement
@@ -242,7 +242,7 @@ templates:
pre_commands:
- ATSH6A8
- ATCRA688
formula: (b*256+a-floor(b/128)*65536)*16
formula: (a*256+b-floor(a/128)*65536)*16
unit: km
device_class: distance
state_class: measurement
@@ -485,3 +485,46 @@ templates:
accuracy_decimals: 0
entity_category: diagnostic
update_interval: 3600s
- key: psa_fuel_level_pct
mode: '22'
pid: '0227'
pre_commands:
- ATSH7E0
- ATCRA
formula: a*100/255
unit: '%'
state_class: measurement
accuracy_decimals: 0
icon: mdi:gas-station
update_interval: 60s
publish:
deadband: 0.5
min_interval: 60s
- key: psa_fuel_level_l
mode: '22'
pid: 040F
pre_commands:
- ATSH7E0
- ATCRA
formula: (a*256+b-floor(a/128)*65536)*711/1250
unit: L
device_class: volume_storage
state_class: measurement
accuracy_decimals: 1
icon: mdi:gas-station
update_interval: 60s
publish:
deadband: 0.3
min_interval: 60s
- key: psa_fuel_level_21
mode: '21'
pid: A8
pre_commands:
- ATSH7E0
- ATCRA
formula: (m*256+n)/256
unit: '%'
state_class: measurement
accuracy_decimals: 0
icon: mdi:gas-station
update_interval: 60s