Created
August 27, 2023 17:07
-
-
Save micoli/e5c0e47c241a4da24d1c6796bfafe1c1 to your computer and use it in GitHub Desktop.
websocat zigbee2mqtt devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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