notoriousbdg / Home-AssistantConfig

Apache License 2.0
180 stars 49 forks source link

Invalid state encountered for entity id: sensor.philippe_smartphone_battery. State max length is 255 characters. #4

Closed phdelodder closed 6 years ago

phdelodder commented 6 years ago

I have update to version 1.11 and now I have trouble with battery sensor created from device_trackers:

homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.philippe_smartphone_battery. State max length is 255 characters.
2018-08-23 19:46:33 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 282, in async_update_ha_state
    self.entity_id, state, attr, self.force_update, context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 853, in async_set
    context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 623, in __init__
    "State max length is 255 characters.").format(entity_id))
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.philippe_smartphone_battery. State max length is 255 characters.

MQTT info:

homeassistant/sensor/philippe_smartphone_battery/config {
  "device_class": "battery",
  "name": "Philippe Smartphone Battery",
  "state_topic": "homeassistant/sensor/philippe_smartphone_battery/state",
  "unit_of_measurement": "%",
  "value_template": "{{ value_json.value | int }}",
  "unique_id": "philippe_smartphone_battery",
  "json_attributes": [
    "entity_id",
    "attribute",
    "mqtt_config_topic",
    "mqtt_state_topic"
  ]
}
homeassistant/sensor/philippe_smartphone_battery/state {
  "value":47,
  "entity_id": "device_tracker.philippe_smartphone",
  "attribute": "battery",
  "mqtt_config_topic": "homeassistant/sensor/philippe_smartphone_battery/config",
  "mqtt_state_topic": "homeassistant/sensor/philippe_smartphone_battery/state"
}
notoriousbdg commented 6 years ago

The upgrade can cause that if you haven't restarted after the first state change for that sensor. Try restarting Home Assistant again and let me know if you still get the error after the restart.

phdelodder commented 6 years ago

The errors seem to have stopped after I restarted, meaning I had to restart twice.