Okay, things are getting weird here. I was working on the template sensor solution, and wanted to verify the max size/length of the esphome text sensor before. I couldnt find an “official” documentation entry for the “255 max” anymore. What did strike me though: when looking at the log ouput of the esphome node, the text sensor content was indeed cut off, but way past the supposed 255 characters:
(I’m now wondering if the cutoff in the logs is not because of the sensor size but because of the max length of a log entry…)
Based on the original code, this is the output I could extract from the sensor so far, 10 items from the list:
Just for kicks I increased the document size within arduinoJson from 2048 to 4048, and after compiling and flashing I now get twice the number of bars.
So it looks as if just increasing the document size works for my usecase, and I can just use the existing text sensor to pull data in. But I still want to find the ACTUAL size/length limit of the HA text sensor for future usecases…
For the sake of completeness:
The sensor to pull in the forecast data in esphome (the bottom one):
text_sensor:
- platform: homeassistant
id: outside_weather
entity_id: weather.home
internal: true
- platform: homeassistant
id: owm_forecast
entity_id: weather.openweathermap
internal: true
attribute: forecast
The code to extract and deserialise the JSON coming from the text sensor (where I now switched 2048 to 4048):
- id: page2
lambda: |-
it.printf(0, 0, id(fontsmall), "chance of rain 24h");
it.line(5, 25, 291, 25);
if (id(owm_forecast).has_state())
{
DynamicJsonDocument doc(2048);
deserializeJson(doc, (id(owm_forecast).state.c_str()));
JsonArray root = doc.as<JsonArray>();
int linestart = 5;
for (int i=0; i <= 23; ++i)
{
JsonObject root_0 = root[i];
float root_0_precipitation_probability = root_0["clouds"];
int heighthelper = 1 + (int)root_0_precipitation_probability;
int offsethelper = 125 - heighthelper;
it.filled_rectangle(linestart, offsethelper, 10, heighthelper);
linestart += 12;
}
}
(fyi: I’m using the “clouds” datafield at the moment as there are always values, while chance of rain is mostly zero these days)
Here are 2 examples where I found the 255char limit mentioned: