Scraper platform 255 character state limit

Hi,
Im trying to retrieve a mp3 link from a RSS feed for media player to play when requested. I thought scraper platform would do the trick nicely like this and form a sensor:

  - platform: scrape
    resource: https://feeds.yle.fi/areena/v1/series/1-4489500.rss?lang=fi
    name: podcast_paijathame_uutiset
    select: 'enclosure'
    attribute: url
    index: 0
    scan_interval: 900

Instead of forwarding the scraped data to the sensor state, Hass fails to create the sensor stating that sensor state cant be longer than 255 characters. The link is about 270 char long. Any thoughts how to resolve this and maby some little example?

I also thought rest platform could parse the tag but I dont think the resource page is in the correct format for rest to do its json conversion.

Thanks in advance.

1 Like

Did you do any searches on the topic?

Yes found some via google and the rest workaround seemed a perfect candidate but couldnt figure out how to modify this to fit my needs:

- platform: rest
    name: EC2 Tunnel and Public API
    resource: http://localhost:9002
    value_template: '1'  # dummy value, not used; avoids the "State max length is 255 characters" error
    json_attributes:
      - ec2TunnelState
      - publicApiState
    scan_interval: 120

Ok resolved the issue now based on the old posts. Used Rest platform and attribute instead of value. Attribute does not have the same length limitation:

sensors:
 - platform: rest
    name: paijat hameen uutisten data
    resource: https://feeds.yle.fi/areena/v1/series/1-4489500.rss?lang=fi
    json_attributes_path: "$.rss.channel.item[0].enclosure"
    scan_interval: 900
    value_template: '1' # Dummy template for some reason?
    json_attributes:
      - "@url"

scripts:
...
- service: media_player.play_media
    data:
      media_content_id: '{{ state_attr(''sensor.paijat_hameen_uutisten_data'', ''@url'') }}'
      media_content_type: music
    target:
      entity_id: media_player.toimisto
1 Like