The […] indicates that there are a lot of values in between. In fact this array is quite long and represents an object similar to what a weather forecast API would return.
I tried to add this in my configuration.yaml
rest:
- resource: https://url_to/file.json
scan_interval: 900
sensor:
- name: "Forecast"
value_template: >-
{% for index in value_json["curve_forecast"]["data"] -%}
{{ index }}
{%- endfor %}.
json_attributes:
- "timestamp"
- "astro"
- "curveforecast"
- "measurement"
But I always get this error homeassistant.exceptions.InvalidStateError: Invalid state with length 157668. State max length is 255 characters.
Is there a way to parse the attributes in a way they are defined as a weather forecast-like entity? Do I have to maybe use this Template Weather Provider - Home Assistant?
Ok but first of all I need to store the response JSON of data somewhere in Home Assistant, right? Otherwise I cannot use it into a template weather entity.
Unfortunately the response is too large to be stored into an attribute. I tried doing this
WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.forecast exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
So, I’m not sure how this could be tackled with the default integrations. The idea I had at the beginning was to write my own Python script to run with pyscript-hacs, organize the results and save them into a state.
But it cannot parse an array. If you remove the [:1] nothing get stored in the state attribute. I’m trying to parse the entire array into the attributes. This may just not be the ideal solution…I don’t know how the weather forecast is stored for a weather entity, but this is exactly what I’m trying to achieve.