Created
January 7, 2020 02:56
-
-
Save danward79/310096079cf4aa5cb72aa46cf693cde4 to your computer and use it in GitHub Desktop.
Set Roon ZoneID on a bridge device
This file contains 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 | |
# Endian changed the endiness of the arg | |
endian() | |
{ | |
v=$1 | |
i=${#v} | |
while [ $i -gt 0 ] | |
do | |
i=$[$i-2] | |
endianResult=$endianResult${v:$i:2} | |
done | |
} | |
# Script makes the assumption that there is only one output enabled on the Bridge. On this basis | |
# the script gets the last device file to be created, which will contain the unique_id of the output. | |
# The unique_id is used to create the zone_id | |
deviceFile=$(ls -Art /var/roon/RAATServer/Settings/device_*.json | tail -n 1) | |
echo "File Name: $deviceFile" | |
# The field unique_id is extracted from the device file. | |
# this take the form of 21d58030-868d-1363-89e4-23ada731ca6c | |
uniqueID=$(cat $deviceFile | jq '.unique_id') | |
echo "UniqueID: $uniqueID" | |
endian ${uniqueID:1:8} | |
endian ${uniqueID:10:+4} | |
endian ${uniqueID:15:+4} | |
segment4=${uniqueID:20:+4} | |
segment5=${uniqueID:25:+12} | |
# zone_id starts with 1601, then the unique_id from above. The first three segments are encoded | |
# in big endian instead of little. There are also no hyphens | |
# Using the example above the zone_id would be: | |
# 16013080d5218d86631389e423ada731ca6c | |
zoneID="1601$endianResult$segment4$segment5" | |
echo "ZoneID: $zoneID" | |
echo zoneID=$zoneID >> /etc/roonBridge.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment