Thanks for your suggestion. But i use this sensor to extract a lot of information from my atagone thermostat. And 255 characters is much too small. I think i have to implement another solution. Just now i am thinking of an own rest script that reads the atagone and splits the information in a few files that i can read with the file sensor.
Would be easier to create a custom rest sensor that split the data into attributes of that sensor. Take a look at the pvoutput sensor platform that one is doing this.
The idea of a custom rest-sensor looks great. The pvoutput sensor platform example gives me enough knowledge to implement my own. I will try to implement that.
At the moment i am developing my custom rest sensor. Is there a way to test the code without restarting hass every time i change the code while testing?
That PR doesn’t fix the issue… I have created a 3 line patch in a new PR (https://github.com/home-assistant/home-assistant/pull/21556), that does actually fix this issue… It discards non JSON_attributes field values and truncates value at 255 chars while still allowing all attributes to be associated with the state.
You can’t store more than 255 characters in an entity’s state property.
However, you can store more than 255 characters in an entity’s attribute. Use the json_attributes option to put the received data into one or more attributes. Here’s an example of how to do that:
A workaround for this I use, aligned with @123 above, is using a dummy sensor value and extracting the useful values via json attributes, like so:
- 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
Hello. I am hoping you can help me on this one. I’ve created a template sensor grabbing data from a local calendar event which is over 255 char. The initial creation of the sensor went fine. When it tried to trigger, it has an error in log saying max char 255. Ok fine. So, I have deleted the sensor and the event day that had char over 255.
When I tried to create the same sensor using the same name, I kept getting this char 255 error and the sensor is not visible when I check in developer tools. I can create using a different name, but I wish to continue using that same name. I have tried removing the sensor in core.restore_state and homeassistant.exposed_entities; It keeps returning after a restart of ha and or re creating with the same name in core.restore_state.
{
"state": {
"entity_id": "sensor.units_arriving",
"state": "none",
"attributes": {
"friendly_name": "Units Arriving"
},
"last_changed": "2023-06-08T02:32:14.144551+00:00",
"last_updated": "2023-06-08T02:32:14.144551+00:00",
"context": {
"id": "01H2CDHW2014NZSPHK0KD4P00Z",
"parent_id": null,
"user_id": null
}
},
"extra_data": {
"native_value": "Highway: x1 Container [Evergreen, Green Celebrity],\nMIB: x1 Container [Evergreen Green Celebrity],\nEM: x1 Container [Evergreen, Wan Hai 266],\nAndrew: x2 Containers [Evergreen, Wan Hai 266],\nMEL: x1 Container [Evergreen, Wan Hai 266],\nLY: x3 Containers [Evergreen, Wan Hai 266],\nPaolo x2 Containers [Evergreen, Green Celebrity, Wan Hai 266]",
"native_unit_of_measurement": null
},
"last_seen": "2023-06-08T21:15:16.390805+00:00"
},