Browse Source

add filter "home-assistant-entity-registry" truncating matter fabric id in `unique_id`

Matter entity unique ids contain the 8-byte compressed fabric id, which is shortened to its first 3 bytes as in the device registry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fabian Peter Hammerle 1 day ago
parent
commit
f4ba938e0a
1 changed files with 5 additions and 0 deletions
  1. 5 0
      gitconfig

+ 5 - 0
gitconfig

@@ -67,6 +67,11 @@
 	clean = "jq '(.data.devices[] |= if .manufacturer == \"Victron Energy BV\" then (.name, .serial_number) |= if . != null then sub(\"(?<p>HQ[0-9]{4}[[:alnum:]])[[:alnum:]]{4}(?=[^[:alnum:]]|$)\"; \"\\(.p)…\") else . end elif .manufacturer == \"Valetudo\" then .configuration_url |= if . != null then sub(\"(?<p>://valetudo-[[:alnum:]]{2})[[:alnum:]]+\"; \"\\(.p)…\") else . end else . end) | ((.data.devices[] | select(.manufacturer != \"Victron Energy BV\" and .serial_number != null) | .serial_number) |= if length > 6 then .[:6] + \"…\" else . end) | ((.data.devices[]?, .data.deleted_devices[]?) | .identifiers[]? | select(.[1] != null)) |= if .[0] == \"mobile_app\" then .[1] |= sub(\"^(?<p>[[:xdigit:]]{2})[[:xdigit:]]{14}$\"; \"\\(.p)…\") elif .[0] == \"matter\" then .[1] |= (sub(\"^(?<p>deviceid_[[:xdigit:]]{6})[[:xdigit:]]{10}(?=-)\"; \"\\(.p)…\") | sub(\"^(?<p>serial_[[:xdigit:]]{6})[[:xdigit:]]+$\"; \"\\(.p)…\")) elif .[0] == \"samsungtv\" then .[1] |= sub(\"^(?<p>[[:xdigit:]]{2})[[:xdigit:]]{6}(-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}$\"; \"\\(.p)…\") else . end' | eval \"$(git config --get filter.truncate-mac-address-to-24-bits.clean)\" | eval \"$(git config --get filter.truncate-dyness-battery-serial-numbers.clean)\""
 	smudge = cat
 
+[filter "home-assistant-entity-registry"]
+	clean = "jq '((.data.entities[]?, .data.deleted_entities[]?) | select(.platform == \"matter\" and .unique_id != null) | .unique_id) |= sub(\"^(?<p>[[:xdigit:]]{6})[[:xdigit:]]{10}(?=-[[:xdigit:]]{16}-)\"; \"\\(.p)…\")'"
+	smudge = cat
+	required = true
+
 [filter "truncate-dyness-battery-serial-numbers"]
 	clean = sed -E -e 's/(^|[^[:alnum:]])([Bb][0-9]{6})[0-9]{7}([^[:alnum:]]|$)/\\1\\2…\\3/g'
 	smudge = cat