Browse Source

add filter "home-assistant-device-registry"

Victron Energy devices expose their serial number in the device name. Truncate the last 4 characters, keeping prefix, production year, production week & the following character. Chains filter "truncate-mac-address-to-24-bits", as git applies only one filter per path.

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

+ 5 - 0
gitconfig

@@ -52,6 +52,11 @@
 	smudge = cat
 	required = true
 
+[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 else . end' | eval \"$(git config --get filter.truncate-mac-address-to-24-bits.clean)\""
+	smudge = cat
+
 [filter "truncate-mac-address-to-24-bits"]
 	clean = sed -E     -e 's/(^|[^[:xdigit:]:])([[:xdigit:]]{2}(:[[:xdigit:]]{2}){2})(:[[:xdigit:]]{2}){3}([^[:xdigit:]:]|$)/\\1\\2:…\\5/g'     -e 's/(-[[:xdigit:]]{4}-40e7-(8e6c|9f6c)-[[:xdigit:]]{6})[[:xdigit:]]{6}([^[:xdigit:]]|$)/\\1…\\3/gI'     -e 's/(:[[:xdigit:]]{0,4}:[[:xdigit:]]{0,2}ff:fe)[[:xdigit:]]{2}:[[:xdigit:]]{1,4}([^[:xdigit:]:]|$)/\\1…\\2/gI'     -e 's/(^|[^[:xdigit:]-])([[:xdigit:]]{6})[[:xdigit:]]{6}([^[:xdigit:]]|$)/\\1\\2…\\3/g'
 	smudge = cat