Rest sensor response with message > 255 characters

I am still puzzle how to use the rest sensor in HA. I have a rest type response from a Amtron EV Charger web interface containing data pairs with text > 255 chars. I see many old post. Some posts reference to an update in HA and using value_template: “1” in combination with sensor:
- name: “example” but cannot find any documentation that actually shows a working solution. Anyone can enlighten me what the current status is on how to deal with rest response messages with more than 255 characters?

Use the rest integration with your URL as the resource, and a load of sensors pulling out the data pairs you need, splitting the response into usable chunks.

Response over 255 characters is fine — it’s an entity’s state that is limited to that.

Give a sample response and the data you’re looking for, and we can help. In the interim, as an example, if your data is split like:

key1:value1,key2:value2, (etc)

you could do:

rest:
  - resource: YOUR_URL
    sensor:
      - name: key1
        value_template: "{{ value.split(',')[0].split(':')[1] }}"
      - name: key2
        value_template: "{{ value.split(',')[1].split(':')[1] }}"

Thanks for the quick reply, will have a go at this.
The response from the web (amtron ev charger) gives something like this:
Instead of the index in the split can the string of the first item be used to get to the value of that item?

conn_state:vehicle_connected_type2
auth_state:authorized_for_charging
auth_uid:
time_since_charging_start:1242
meter_wh:101552
power_w:0
transaction_wh:410
cp_id:xxxxxx
ocpp_state:occupied
type2_state:b
type2_proximity:cable_attached
sig_current:0
schuko_state:idle
backend_conn_state:pending
free_charging:on
slave_state:
ocpp_meter_cfg:modbus_meter_nzr
ocpp_meter_serial:xxxxx

Put the response in an attribute which has no such limitations

Another alternative is to load the response as an attribute via a curl in a comman_line sensor
Example (example only):

command_line:   
  - sensor:
        name: somename
        unique_id: some_name
    command: >
         echo "{\"events\":" $(
         curl 
         -s 
         'https://api.fingrid.fi/v1/variable/336/events/json?start_time={{ (now()-timedelta(hours=4)).strftime('%Y-%m-%dT%H:%M:%SZ') }}&end_time={{ (now()+timedelta(hours=12)).strftime('%Y-%m-%dT%H:%M:%SZ') }}'
         ) "}" 
    value_template: > 
        {{ value_json.events | length }}
    json_attributes:
        - events

Yes:

{{ value|regex_findall('free_charging:(.*)\n')|first }}

Opted for the following approach:

rest:
    scan_interval: 60
    resource: http://x.x.x.x/rest/full_state
    sensor:
      - name: "Amtron conn_state"
        value_template: >
          {{ value.split("\n")[0].split(':')[1] }}
      - name: "Amtron auth_state"
        value_template: >
          {{ value.split("\n")[1].split(':')[1] }}
      - name: "Amtron Energy"
        value_template: >
          {{ value.split("\n")[4].split(':')[1] }}
        unit_of_measurement: "Wh"
        device_class: energy
        state_class: total_increasing
      - name: "Amtron Power"
        value_template: >
          {{ value.split("\n")[5].split(':')[1] }}
        unit_of_measurement: "W"
        device_class: power
      - name: "Amtron OCPP State"
        value_template: >
          {{ value.split("\n")[8].split(':')[1] }}
      - name: "Amtron Charging Current"
        value_template: >
          {{ value.split("\n")[18].split(':')[1] }}
        unit_of_measurement: "A"
        state_class: measurement
      - name: "Amtron Signaled Current"
        value_template: >
          {{ value.split("\n")[19].split(':')[1] }}
        unit_of_measurement: "A"
        state_class: measurement
      - name: "Amtron temperature"
        value_template: >
          {{ value.split("\n")[20].split(':')[1] }}
        unit_of_measurement: "°C"
        device_class: temperature
1 Like