This repository has been archived on 2026-11-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
hassble-config/templates.yaml
T
eiggerandClaude Opus 5 f86de06da4 fix(obd): read the Accent transmission with mode 22, not mode 21
Removing these sensors was the wrong call. The header was right and the app
parsed the reply correctly — the service mode was wrong.

21 A0 at 7E1 answers on this car, but only ever with 61A0FFFF0000: four data
bytes, FF FF 00 00, identical across all 115 responses in the logs. The
awesomeit profile reads bytes 13, 20 and 21 from this block, all past the end
of that stub, so nothing could ever be published.

The Carnival YP diagnostic log shows what that stub is a truncation of. On the
same 7E1:

    21 A0    -> 7F 21 11 (serviceNotSupported)
    22 01A0  -> 6201A0 FF FF 84 00 00 00 00 13 ...   (42-byte multi-frame)

Both replies open with FF FF, so the Accent's mode 21 answer looks like an
abbreviated form of the same block, with the real contents behind mode 22.
The awesomeit profile's 21 A0 is likely written for an older TCU generation.

Restore the three sensors with mode 22 and DID 01A0, keeping awesomeit's byte
positions unchanged so only the mode differs. Flow control is set the way the
Carnival log sets it before querying 7E1, since the full reply is multi-frame.
If this car answers short or negatively, decode returns null and the sensors
stay empty rather than reporting nonsense, and the log will say which.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-01 22:19:46 +09:00

418 lines
18 KiB
YAML

# Device templates for HassBle app → Sensors tab → Import template
# Loaded from repo root as templates.yaml (same branch as config.yaml)
templates:
- id: jaalee_jht
name: "Jaalee JHT"
description: "Temperature / humidity / battery (iBeacon, Apple manufacturer 76)"
device:
id: jaalee_jht
name: "Jaalee JHT"
source: advertisement
instance_mode: mac
match:
manufacturer_id: 76
manufacturer_min_length: 24
manufacturer_hex_prefix: "0215"
sensors:
- key: temperature
device_class: temperature
unit: "°C"
state_class: measurement
accuracy_decimals: 2
source_field: manufacturer_data
decode: { offset: 18, length: 2, type: uint16, endian: big, scale: 0.002670288, offset_value: -45 }
- key: humidity
device_class: humidity
unit: "%"
state_class: measurement
accuracy_decimals: 2
source_field: manufacturer_data
decode: { offset: 20, length: 2, type: uint16, endian: big, scale: 0.001524504 }
- key: battery
device_class: battery
unit: "%"
state_class: measurement
source_field: manufacturer_data
decode: { offset: 23, length: 1, type: uint8 }
- id: parking_beacon
name: "Parking Beacon"
description: "Shared parking beacon (manufacturer 861 / 0x035D)"
device:
id: parking_beacon
name: "Parking Beacon"
source: advertisement
instance_mode: shared
match:
manufacturer_id: 861
sensors:
- key: parking_time
device_class: timestamp
icon: mdi:clock-time-four-outline
source_field: manufacturer_data
length: 14
decode: { offset: 7, length: 4, type: timestamp }
- key: parking_floor
icon: mdi:layers-outline
source_field: manufacturer_data
length: 14
accuracy_decimals: 0
decode: { offset: 11, length: 1, type: uint8, scale: -1, offset_value: 256 }
- key: parking_location
platform: text_sensor
icon: mdi:map-marker-outline
source_field: manufacturer_data
length: 14
decode: { offset: 12, length: 2, type: string }
- id: obd_standard
name: "OBD-II (standard PIDs)"
description: "RPM, speed, coolant, fuel — bind ELM327 adapter in app"
device:
id: obd_vehicle
name: "OBD Vehicle"
source: obd
obd:
service_uuid: "FFF0"
tx_char_uuid: "FFF2"
rx_char_uuid: "FFF1"
tx_delay: 50ms
init_commands: []
sensors:
- { key: rpm, preset: rpm, update_interval: 1s }
- { key: speed, preset: speed, update_interval: 1s }
- { key: coolant_temp, preset: coolant_temp, update_interval: 10s }
- { key: fuel_level, preset: fuel_level, update_interval: 60s }
- id: obd_gm_extended
name: "OBD-II + GM extensions"
description: "Standard PIDs plus GM mode-22 sensors (ATSP6 init)"
device:
id: car_obd
name: "Vehicle OBD"
source: obd
obd:
service_uuid: "18F0"
tx_char_uuid: "2AF1"
rx_char_uuid: "2AF0"
tx_delay: 50ms
init_commands: ["ATSP6"]
sensors:
- { key: rpm, preset: rpm, update_interval: 1s }
- { key: speed, preset: speed, update_interval: 1s }
- { key: coolant_temp, preset: coolant_temp, update_interval: 10s }
- key: fuel_level
preset: fuel_level
update_interval: 60s
publish: { deadband: 0.5, min_interval: 60s }
- { key: gear, preset: gm_current_gear, update_interval: 2s }
- { key: prnd, preset: gm_prnd_status_alt, update_interval: 2s }
- { key: oil_pressure, preset: gm_oil_pressure, update_interval: 5s }
- { key: trans_temp, preset: gm_trans_temp, update_interval: 10s }
- id: obd_hyundai_kia
name: "OBD-II + 현대/기아 계기판"
description: "RPM, 속도, 총 주행거리, 연료잔량(L), 계기판 전압 — 계기판 7C6 / 22B002"
device:
id: car_obd_hk
name: "Hyundai/Kia OBD"
source: obd
obd:
service_uuid: "18F0"
tx_char_uuid: "2AF1"
rx_char_uuid: "2AF0"
tx_delay: 50ms
init_commands: ["ATSP6"]
# default_commands 생략 — 아래 ATSH7C6 센서가 있으므로 앱이 ATSH7DF로 자동 복원
sensors:
- { key: rpm, preset: rpm, update_interval: 1s }
- { key: speed, preset: speed, update_interval: 1s }
# 계기판(CLU) UDS. 요청 7C6 → 응답 7CE. 한 응답에 주행거리·연료·전압이 함께 온다.
# 응답: 62 B0 02 [a][b][c][d][e][f][g][h][i][j][k][l]…
# (a = 62B002 에코 바로 다음 바이트)
# e → 연료잔량 e*0.5 L
# f → 계기판 전압 f/12.8 = f*0.078125 V
# g:h:i → 총 주행거리 24bit km
# j:k:l → 위와 같은 주행거리의 mile 값 (북미 사양 계기판)
# 출처: OBDb(obdb.community)에서 현대·기아 11개 차종이 동일한 바이트 배치로 확인.
# awesomeit Torque 플러그인(35개 차종)·Elantra CN7 PID 목록과도 일치.
# 2013년식 이후에서 널리 동작하며, 미지원 차는 NO DATA를 반환한다.
#
# 예외: 엑센트(RB)는 계기판이 이 DID를 열지 않는다. 2013/2015/2019 실차 캡처에서
# unsupported로 확인됐고 (2018년식만 예외), 요청하면 7F 22 22를 돌려준다.
# 엑센트는 아래 obd_hyundai_accent_rb_diesel 템플릿을 쓸 것.
- key: odometer
mode: "22"
pid: "B002"
pre_commands: ["ATSH7C6"]
formula: "g*65536+h*256+i"
unit: "km"
device_class: distance
state_class: total_increasing
accuracy_decimals: 0
icon: mdi:counter
update_interval: 60s
- key: fuel_level
mode: "22"
pid: "B002"
pre_commands: ["ATSH7C6"]
formula: "e*0.5"
unit: "L"
state_class: measurement
accuracy_decimals: 1
icon: mdi:gas-station
update_interval: 60s
publish: { deadband: 0.5, min_interval: 60s }
- key: cluster_voltage
mode: "22"
pid: "B002"
pre_commands: ["ATSH7C6"]
formula: "f*0.078125"
unit: "V"
device_class: voltage
state_class: measurement
accuracy_decimals: 2
entity_category: diagnostic
update_interval: 120s
- id: obd_hyundai_accent_rb_diesel
name: "OBD-II 엑센트(RB) 디젤"
description: "RPM, 속도, 연료 %, 흡기온도, 대기압 + 총주행거리 프로브 — 엑센트 RB 1.6 TCI-U2"
device:
id: car_obd_accent
name: "Accent RB Diesel"
source: obd
obd:
service_uuid: "18F0"
tx_char_uuid: "2AF1"
rx_char_uuid: "2AF0"
tx_delay: 50ms
init_commands: ["ATSP6"]
# 아래 ATSH7E0 센서가 있으므로 표준 센서 앞에 ATSH7DF가 자동 삽입된다
sensors:
- { key: rpm, preset: rpm, update_interval: 1s }
- { key: speed, preset: speed, update_interval: 1s }
# 연료량은 이 차에서 읽을 방법이 없다. 표준 01 2F는 실차에서 NO DATA를
# 돌려주고(OBDb 캡처는 북미 가솔린 기준이라 디젤에는 맞지 않았다),
# 계기판 22B002도 7F 22 22로 거부한다.
# awesomeit 엑센트RB 2013 D 1.6 TCI-U2 프로필에서 확인된 값들
- key: intake_temp
mode: "21"
pid: "01"
pre_commands: ["ATSH7E0"]
formula: "k*0.980392-50"
unit: "°C"
device_class: temperature
state_class: measurement
accuracy_decimals: 1
update_interval: 20s
- key: barometric_pressure
mode: "21"
pid: "01"
pre_commands: ["ATSH7E0"]
formula: "j*1.372549"
unit: "kPa"
device_class: pressure
state_class: measurement
accuracy_decimals: 1
update_interval: 60s
# ── 총주행거리 (엔진 ECU의 DPF 블록에 같이 실려 온다) ──────────────
# 엑센트 RB는 계기판(7C6 / 22B002)이 주행거리를 직접 내주지 않는다 —
# 요청하면 7F 22 22. 그래서 대안으로 엔진 ECU의 21 03 블록을 쓴다
# (OBDb 메이커 공용 HYUNDAI_ODO_V2):
# byte 49~52 마지막 DPF 재생 시점의 주행거리 /1000 km
# byte 53~56 재생 이후 달린 거리 /1000 km
# byte 57~60 총주행거리 /1000 km ← 목표
# 셋은 서로 다른 필드다. awesomeit이 "DPF 주행거리"로 부르는 건 byte 53(재생 후 거리).
#
# 응답이 byte 57까지 도착하지 않으면 decode가 null을 돌려주고 아무것도
# 발행되지 않는다 — 미지원 차에서 엉뚱한 값이 올라오지 않는다.
#
# 보정: 2026-07-30 실측에서 이 ECU 카운터가 계기판(195958 km)보다
# 0.7331% 높게(197394.5 km) 나왔다. 처음엔 상수(offset_value)로 보정했으나
# 신차(카운터=0)에서 dash=-1436.5km 가 나오는 게 되어 성립할 수 없다.
# 배율(scale) 보정은 원점을 지나므로(카운터=0 → dash=0) 물리적으로 맞다 —
# 이 카운터는 계기판과 별개 환산계수로 바퀴속도 펄스를 거리로 누적하는
# 서비스용 값이라, 오차가 주행거리에 비례해 벌어지는 게 정상이다.
# 세 필드가 odometer = at_regen + since_regen 항등식을 만족하려면
# 셋 다 같은 배율을 써야 한다 (상수 보정과 달리 since_regen도 예외 없음).
#
# 측정이 한 점뿐이라 배율만 가정했고 절편은 0으로 뒀다. 100km 이상
# 주행 후 재확인해 두 점으로 완전한 affine 식(scale·offset_value 둘 다)을
# 풀 것 — 아래 odometer_flow_control 이 계기판 값을 직접 준다면 이 보정
# 자체가 필요 없어지므로 그쪽을 먼저 확인한다.
# 오도미터는 분 단위로 갱신될 필요가 없고, 63바이트 멀티프레임이라 짧은
# PID보다 무겁다 — 주기를 늘리는 게 배터리에 가장 크게 도움되는 지점이다.
- key: odometer
mode: "21"
pid: "03"
pre_commands: ["ATSH7E0"]
decode: { offset: 57, length: 4, type: uint32, endian: big, scale: 0.000992723 }
unit: "km"
device_class: distance
state_class: total_increasing
accuracy_decimals: 1
icon: mdi:counter
update_interval: 300s
# 검산용: 재생시점 주행거리 + 재생후 거리 = 총주행거리.
# 셋 다 같은 카운터를 공유하므로 같은 배율을 적용해야 항등식이 유지된다.
- key: odometer_at_last_dpf_regen
mode: "21"
pid: "03"
pre_commands: ["ATSH7E0"]
decode: { offset: 49, length: 4, type: uint32, endian: big, scale: 0.000992723 }
unit: "km"
device_class: distance
state_class: total_increasing
accuracy_decimals: 1
entity_category: diagnostic
update_interval: 300s
- key: distance_since_dpf_regen
mode: "21"
pid: "03"
pre_commands: ["ATSH7E0"]
decode: { offset: 53, length: 4, type: uint32, endian: big, scale: 0.000992723 }
unit: "km"
device_class: distance
state_class: measurement
accuracy_decimals: 1
entity_category: diagnostic
update_interval: 300s
# ── 계기판 오도미터 재시도: 확장 진단 세션 ─────────────────────────
# 위 odometer 는 어디까지나 대체 경로(추정 보정)다. 진짜 계기판 값을
# 직접 받을 가능성이 아직 남아 있다 — 7F 22 22 의 NRC 22(conditionsNotCorrect)는
# UDS 표준상 "그 DID는 존재하는데 지금 조건에서 거부"라는 뜻이다.
# DID 자체가 없다는 NRC 11(serviceNotSupported)·31(requestOutOfRange)이 아니었다.
#
# meatpiHQ/wican-fw#478 에서 같은 헤더(7C6)·같은 PID(22B002)로 실제 성공한
# 사례 둘을 확인했다: 아이오닉 28kWh(WiCAN, pid_init "ATSH7C6;ATFCSH7C6")와
# 아이오닉5(canair, 세션 명령 없이 바로 조회). 둘 다 확장 세션(10 03) 없이
# 됐고, 공통점은 흐름제어(ATFCSH) 설정뿐이었다. 그래서 세션 대신 흐름제어를
# 먼저 시도한다 — 실제 성공 사례에 더 가깝다.
#
# 오도미터 위치도 세대별로 다르다: 아이오닉5·OBDb ICE 11개 차종은 byte
# 6~8(g,h,i)인데, 구형 아이오닉 28kWh는 byte 9~11(j,k,l)이었다
# (WiCAN이 ISO-TP PCI 바이트를 페이로드에 섞어 넣는 별도 버그가 있어,
# 그 이슈에서 공개한 보정표로 실제 위치를 역산한 값). 응답은 왔는데
# 195958과 안 맞으면 formula 를 "j*65536+k*256+l" 로 바꿔서 재시도할 것.
#
# pre_commands 자체의 응답(흐름제어 설정 OK/에러)은 로그에 안 남지만
# (해당 응답을 기다리는 센서가 없어 기록 경로를 안 탄다), 뒤따르는
# 22B002 응답은 그대로 남는다.
# raw=62B002… → 성공. 계기판 값이 보정 없이 직접 나온다
# negative response 그대로 → 흐름제어도 소용없음. 세션(10 03)으로 한 번 더
# 시도해볼 수는 있으나, 위 두 성공 사례 모두 세션 없이 됐다는 점에서
# 이 차는 DID 자체가 없을 가능성이 이전보다 높아졌다.
- key: odometer_flow_control
mode: "22"
pid: "B002"
pre_commands: ["ATSH7C6", "ATFCSH7C6", "ATFCSD300000", "ATFCSM1"]
formula: "g*65536+h*256+i"
unit: "km"
device_class: distance
state_class: total_increasing
accuracy_decimals: 0
entity_category: diagnostic
update_interval: 300s
# 계기판(22B002)·표준(01A6)·변속기(21A0) 오프셋 0~15 스캔은 195958km와
# 일치하는 값을 찾지 못해 제거했다. 계기판은 애초에 22B002 자체를
# 7F 22 22로 거부하므로 다른 DID를 더 뒤져볼 이유가 약하고, 표준 01A6은
# mode 01 지원 목록에 없어 예상대로였다. 위 offset_value 보정을 계속 쓴다.
# ── 변속기(TCU) @ 7E1 — mode 22 로 재시도 ──────────────────────────
# awesomeit 프로필의 21 A0 (mode 21)은 이 차에서 스텁만 돌려준다.
# 실측 115건이 전부 61A0FFFF0000 — 에코를 뺀 데이터가 4바이트(FF FF 00 00)
# 고정이라, 프로필이 읽는 byte 13/20/21 은 전부 범위 밖이었다.
# 헤더(7E1)도 파싱도 문제가 아니었고, 서비스 모드가 달랐던 것이다.
#
# 카니발(YP F/L 2018) 진단 로그에서 같은 7E1 에 대해:
# 21 A0 → 7F 21 11 (serviceNotSupported)
# 22 01A0 → 6201A0 FF FF 84 00 00 00 00 13 … (42바이트 멀티프레임)
# 엑센트의 21A0 응답도 FF FF 로 시작하는 걸 보면 같은 블록의 축약본이고,
# 실제 내용은 mode 22 쪽에 있는 것으로 보인다. awesomeit 의 21A0 은
# 더 구형 TCU 세대 기준이었을 가능성이 크다.
#
# 바이트 위치는 awesomeit 프로필 그대로 두고 모드만 바꿔 확인한다.
# 응답이 짧으면 decode 가 null 을 돌려주므로 값이 안 올라올 뿐 안전하다.
# 흐름제어는 카니발 로그가 7E1 조회 전에 설정한 것과 동일하게 맞췄다.
# raw=6201A0FFFF84… → 성공. 세 값이 맞는지 기어를 바꿔가며 확인할 것
# NO DATA / 7F → 이 차 TCU 에는 없는 것으로 확정하고 셋 다 지운다
- key: trans_oil_temp
mode: "22"
pid: "01A0"
pre_commands: ["ATSH7E1", "ATFCSH7E1", "ATFCSD300000", "ATFCSM1"]
decode: { offset: 13, length: 1, type: uint8, offset_value: -40 }
unit: "°C"
device_class: temperature
state_class: measurement
accuracy_decimals: 1
icon: mdi:oil-temperature
entity_category: diagnostic
update_interval: 20s
- key: gear_position
mode: "22"
pid: "01A0"
pre_commands: ["ATSH7E1", "ATFCSH7E1", "ATFCSD300000", "ATFCSM1"]
platform: text_sensor
icon: mdi:car-shift-pattern
entity_category: diagnostic
decode:
offset: 20
length: 1
type: uint8
map:
"8": "D"
"9": "N"
"10": "R"
"11": "P"
"12": "Sport"
"16": "E Mode"
update_interval: 2s
- key: gear
mode: "22"
pid: "01A0"
pre_commands: ["ATSH7E1", "ATFCSH7E1", "ATFCSD300000", "ATFCSM1"]
platform: text_sensor
icon: mdi:numeric
entity_category: diagnostic
decode:
offset: 21
length: 1
type: uint8
map:
"0": "P/N"
"1": "1"
"2": "2"
"3": "3"
"4": "4"
"5": "5"
"6": "6"
"7": "7"
"8": "8"
update_interval: 2s
- id: gatt_meter_relay
name: "GATT power meter + relay"
description: "Notify characteristic + switch control example"
device:
id: custom_meter
name: "Custom BLE Meter"
source: gatt_notify
gatt:
service_uuid: "ffe0"
notify_char_uuid: "ffe1"
write_char_uuid: "ffe2"
sensors:
- key: power
unit: "W"
device_class: power
state_class: measurement
decode: { offset: 0, length: 2, type: uint16, endian: little }
controls:
- key: relay
type: switch
command: { on: "A10100", off: "A10000" }