Logger: homeassistant.helpers.entity
Source: helpers/entity.py:906
First occurred: 07:27:59 (11 occurrences)
Last logged: 11:27:42
Failed to set state, fall back to unknown
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 906, in _async_write_ha_state
hass.states.async_set(
File “/usr/src/homeassistant/homeassistant/core.py”, line 1687, in async_set
state = State(
^^^^^^
File “/usr/src/homeassistant/homeassistant/core.py”, line 1264, in init
validate_state(state)
File “/usr/src/homeassistant/homeassistant/core.py”, line 184, in validate_state
raise InvalidStateError(
homeassistant.exceptions.InvalidStateError: Invalid state with length 256. State max length is 255 characters.
Nice to have logging. Would be more nice to know which entity !
sounds like a template/automation, this entity 'action" , not that i know whether it’s the one “referred to” in the trace
Normally(not often) when i can’t figure out anything, with current “logger ERROR” i set logger to “DEBUG” and “restart/reproduce/”… just out of curiosity
found it.
it was a template helper. The result was too long.
I have a template helper that counts lights that are on (als one that count “off” lights, and unavailable lights)
But i made also a helper where the result was the light entities that were on. Apparantly, the result was too long. I guess I have to find a way to make it an attribute of the helper. But, I think that is not possible yet with the template helper (ui version)
well it was possible to use it in an auto-entities card (ui)
{{ states(“sensor.template_lights_on”) }}
I have a dashboards for PC, for Smartphone,… so, some data are displayed in more than one dashboard. I don’t like to duplicate routines/scripts/… so the helper template was perfect. Only, the length of the result of the helper template is limited…
yes, a helper or template-sensor is not the right/best choice for this case, i.e a script does not have a “state” and is therefore, not in the state-engine, i would suggest you just use your “template” direct in the autoentities-card, instead of creating a template-sensor(listing names of all lights.on) out of it,
I’ts awhile since i used/configured an auto-entities-card, but as i remembered it, there are both the option to set/pick i.e “domain” and list with “state-conditions” , which makes the template irrelevant
Don’t see the need for the ‘state’
There are even helper groups, and other kinds of helpers.
It feels like the template helper is the UI version of custom_templates. Easier to manage.
The solution I have now, the use of custom_templates, is not very user friendly.
It’s not deal breaker for me, as a programmer, but for beginners…
But you indeed made a Helper with a state, which exceeded the max length of 256 ( do to listing all names of light in the state “on” )
Which you wanted to use in a Custom_auto-entities card
Where you can use multiple Options , i.e “include” lights.xxxxx* , with the “Filter” i.e state “on” == NO Need for template a list of “lights on” , that’s what auto-entities is build for.
I think a “beginner” would/should be able to follow the docs, for the Auto-entities.card.
If they later on should get tempted of feel a need of using “templates” , or/and also use “helpers”, i doubt it would be for use in an Auto-entities-card, unless any of the multiple build-in options couldn’t satisfy the usecase
Bottom line is, there is hardly any of your commends which have a “positive” touch, nor your “Topic Header”
Spite people trying to offer you a helping hand, everything seems/sounds wrong in your head
type: custom:auto-entities
card:
type: entities
filter:
template: |
{% for light in states.light %}
{% if light.state == "on" %}
{{ light.entity_id}},
{% endif %}
{% endfor %}
To much logic for you ? … As a “Programmer”
PS: this is just an example, from the Auto-Entities-Card , DOCS