I scrape a text from a website to show it on my dashboard. However, the state of a sensor is apparently limited to a max of 255 characters. Is there another solution how it can be done?
This is my current setup with scrape, which works as long as the text is max 255 characters:
Thanks for your reply. However, I fail to get it working. …and to be honest, I also do not understand how the value_template setting shall be of help if the text is more than 255 characters? Would be great if you could provide an example.
As you have already discovered, the maximum length that can be stored in an entity’s state is 255 characters. An entity’s attributes can store up to 16KB but the Scrape integration doesn’t support the use of attributes.
There’s a custom integration called Multiscrape that does support the use of attributes.
If you need the complete extract then look at what Taras wrote, else the value template can cut back the returned value to what you want…or to less than 255 {{ value[0:254] }}
It took me some time to figure out exactly how Multiscrape works, but I finally got it right. Here is my working setup for a text with more than 255 characters:
# configuration.yaml
multiscrape:
- resource: [any website url]
scan_interval: 3600
sensor:
- name: "[any sensor name]"
select: "[any selector path for the sensor name]"
value_template: '{{ value }}'
attributes:
- name: [any attribute name]
select: "[any selector path for the attribute]"
value_template: '{{ value }}'
But note that the value for the sensor name must always be less than 255 characters, otherwise the sensor will not be created. The attribute can hold text with more than 255 characters.