Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 103101

New Sonos Favourites sensor - iterate through values

$
0
0

Hi - I am trying to iterate through the list of favourites in the new sensor.sonos_favorites, in order to populate an openHASP display field.

My old code looked like the block below, note I have presented it this way to make it readable - actually this is all on one line in my code:

{%for source in state_attr('media_player.sunroom','source_list')%}
  {{source+"\n"|e}}
  {%-if not loop.last%}{%-endif%}
{%-endfor%}

Under the old Sonos integration a couple of versions ago this produced a list of radios station favourites.

The new one looks like:

{%for item in state_attr('sensor.sonos_favorites','items')%}
  {{item+"\n"|e}}
  {%-if not loop.last%}{%-endif%}
{%-endfor%}

Rather that the station names - I get:

Result type: string
FV:2/4
FV:2/6
FV:2/5
This template listens for the following state changed events:

Entity: sensor.sonos_favorites

If you look at the source data - this is the first part in the attribute field:

Attributes

items: 
FV:2/4: Edge FM
FV:2/6: hit104.9 The Border
FV:2/5: Triple M The Border 105.7

unit_of_measurement: items
icon: mdi:star
friendly_name: Sonos Favorites

Is there a way to extract the actual name?

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 103101

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>