Browse Source

filter "home-assistant-device-registry": also shorten matter fabric ids & serials

The compressed fabric id is 8 bytes long and identifies the Matter fabric, i.e. the installation; only its first 3 bytes are kept. Serial numbers are hardware-bound, so they are shortened to 3 bytes as well.

The mobile_app rule is merged into the same identifier loop without changing its behavior.

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

+ 1 - 1
gitconfig

@@ -64,7 +64,7 @@
 
 [filter "home-assistant-device-registry"]
 	required = true
-	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[]?, .data.deleted_devices[]?) | .identifiers[]? | select(.[0] == \"mobile_app\") | .[1]) |= if . != null then sub(\"^(?<p>[[:xdigit:]]{2})[[:xdigit:]]{14}$\"; \"\\(.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)\""
+	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[]?, .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)…\")) 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 "truncate-dyness-battery-serial-numbers"]