Skip to content

Instantly share code, notes, and snippets.

@danward79
Created January 7, 2020 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danward79/310096079cf4aa5cb72aa46cf693cde4 to your computer and use it in GitHub Desktop.
Save danward79/310096079cf4aa5cb72aa46cf693cde4 to your computer and use it in GitHub Desktop.
Set Roon ZoneID on a bridge device
#!/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