Det er ikke løsningen du spør etter, men i Homeseer bruker jeg script som setter en device value, basert på hvilken kanal som er valgt i en annen device. På den måten får jeg opp metadata om sang, artist/program osv. I HS Touch vises logoen til radiokanalen som spilles, men jeg har ikke funnet noe måte å hente inn det bildet som kommer opp på DAB-radioer.
Imports System.Collections.Generic
Imports System.Net
Imports System.Text
' ChatGPT - May 2, 2023
Sub Main(ByVal Parms As Object)
Dim radioChannels As New Dictionary(Of Integer, String)
radioChannels.Add(10, "https://lyd.nrk.no/nrk_radio_p1_buskerud_aac_h.xspf")
radioChannels.Add(20, "https://lyd.nrk.no/nrk_radio_p2_aac_h.xspf")
radioChannels.Add(30, "https://lyd.nrk.no/nrk_radio_p3_aac_h.xspf")
radioChannels.Add(40, "https://lyd.nrk.no/nrk_radio_alltid_nyheter_aac_h.xspf")
radioChannels.Add(45, "https://lyd.nrk.no/nrk_radio_p13_aac_h.xspf")
radioChannels.Add(50, "https://lyd.nrk.no/nrk_radio_jazz_aac_h.xspf")
radioChannels.Add(60, "https://lyd.nrk.no/nrk_radio_mp3_aac_h.xspf")
radioChannels.Add(70, "https://lyd.nrk.no/nrk_super_aac_h.xspf")
' Add additional radio channels here
Dim radioChannelDeviceRef As Integer = 964
Dim radioChannelValue As Integer = hs.DeviceValue(radioChannelDeviceRef)
If radioChannels.ContainsKey(radioChannelValue) Then
Dim xspfUrl As String = radioChannels(radioChannelValue)
Dim xmlDoc As New XmlDocument()
' Download the XSPF file from the URL
Using webClient As New WebClient()
Dim xspfBytes As Byte() = webClient.DownloadData(xspfUrl)
Dim xspfContent As String = Encoding.UTF8.GetString(xspfBytes)
xmlDoc.LoadXml(xspfContent)
End Using
Dim nsManager As New XmlNamespaceManager(xmlDoc.NameTable)
nsManager.AddNamespace("xspf", "http://xspf.org/ns/0/")
Dim trackList As XmlNodeList = xmlDoc.SelectNodes("/xspf:playlist/xspf:trackList/xspf:track", nsManager)
' Example: Extract track titles and display them in HomeSeer
Dim trackTitles As New List(Of String)
For Each trackNode As XmlNode In trackList
Dim titleNode As XmlNode = trackNode.SelectSingleNode("xspf:title", nsManager)
If titleNode IsNot Nothing Then
trackTitles.Add(titleNode.InnerText)
End If
Next
' Set a device string to display the track titles
Dim deviceRef As Integer = 965
' hs.WriteLog("XSPF-Mottaker", "Track titles: " & String.Join(", ", trackTitles))
' hs.WriteLog("XSPF-Mottaker", "Device ref: " & deviceRef.ToString())
hs.SetDeviceString(deviceRef, String.Join(", ", trackTitles), True)
'Else
' hs.WriteLog("XSPF-Mottaker", "No URL found for the selected radio channel (Value: " & radioChannelValue.ToString() & ")")
End If
End Sub