Skip to content

Instantly share code, notes, and snippets.

@micoli
Created August 27, 2023 17:07
Show Gist options
  • Save micoli/e5c0e47c241a4da24d1c6796bfafe1c1 to your computer and use it in GitHub Desktop.
Save micoli/e5c0e47c241a4da24d1c6796bfafe1c1 to your computer and use it in GitHub Desktop.
websocat zigbee2mqtt devices
#!/bin/bash
# example ./zigbee-report.sh 192.168.2.100
websocat ws://$1 --max-messages-rev 5 -U -B 2621440 | grep "bridge/devices" > /tmp/zigbeedevices.json
echo "Count"
cat /tmp/zigbeedevices.json | jq '.payload | {total: length}'
echo "Detailed Count"
cat /tmp/zigbeedevices.json | jq -r '.payload | group_by (.type)| map({type: .[0].type, count: length}) | reduce .[] as $line ({}; . *= {(($line.type[:1]|ascii_downcase)+($line.type[1:])):($line.count)})'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment