Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- IP="192.168.1.15"
- NAME="SkyQ Black"
- DIR="/home/homeassistant/.homeassistant/packages"
- FILE_MP="skyq_mediaplayer.yaml"
- FILE_CH="skyq_channels.yaml"
- echo "Creating/Updating ${DIR}/${FILE_MP} file..."
- echo "
- media_player:
- - platform: skyq
- name: ${NAME}
- host: ${IP}
- #config_directory: '${DIR}/'
- #generate_switches_for_channels: true
- sources:" > ${DIR}/${FILE_MP}
- echo "Creating/Updating ${DIR}/${FILE_CH} file..."
- echo "
- switch:
- - platform: template
- switches:" > ${DIR}/${FILE_CH}
- echo "Getting SkyQ channel list..."
- BODYRESPONSE=$(curl -s --location --request GET ${IP}:9006/as/services)
- echo "Updating channel list..."
- services=$( jq -r '.services' <<< "${BODYRESPONSE}" )
- for row in $(echo "${services}" | jq -r '.[] | @base64'); do
- channelName=`echo ${row} | base64 --decode | jq -r ${1} '.t' | tr -d ' ' | tr -d \' | sed 's/#//'`
- channelNr=`echo ${row} | base64 --decode | jq -r ${1} '.c'`
- channelNrCmd=`echo ${row} | base64 --decode | jq -r ${1} '.c' | sed 's/\(.\{1\}\)/\1,/g' | sed 's/.$//'`
- echo " "${channelName}: \'${channelNrCmd}\' >> ${DIR}/${FILE_MP}
- echo " canale_${channelNr}:
- value_template: '{{\"off\"}}'
- turn_on:
- service: media_player.select_source
- data:
- entity_id: media_player.skyq_black
- source: '${channelName}'
- turn_off:
- service: script.placeholder" >> ${DIR}/${FILE_CH}
- done
- echo "Done!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement