Jinja Wizards : How do I get the total string length from a list sensor and not the number of list entries?

I need to set a delay based on the amount of characters within the list, I’m currently using ESPhome to send the value to HA via MQTT and then delay by that value but it’s incredibly messy as the project grows.

Using “| length” I get the amount of entries in the list. The sensor data is extracted using the following syntax


and I’m using the following to extract the length in ESPHome and send it via MQTT back to HA :

- mqtt.publish:

          topic: feedlength

          payload: !lambda |-

            return esphome::to_string(id(feed).state.length());

The source of the data is the Feedparsers HACS component : GitHub - custom-components/feedparser: 📰 RSS Feed Integration

{{ state_attr('sensor.feed','entries') 
| map(attribute='title') | join(' ') | count }}
1 Like

Thank you. I’d gone through most of the Jinja docs and was obviously too distracted by the length operator.