HA keeps restarting every 5-10 minutes

Hi guys,

Weird issue. Been running HA for years, never an issue. Since a couple of version, HA keeps restarting every 5-10 min. I was running on Rpi4 and it got really hot. Thought it was the Rpi4 that was the issue so installed HA OS on a mini pc and after restoring, I get the same issue. It seems related to
2023-09-15 16:57:35.829 ERROR (MainThread) [homeassistant.helpers.entity] Failed to set state, fall back to unknown

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 856, in _async_write_ha_state
    hass.states.async_set(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1645, 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 180, in validate_state
    raise InvalidStateError(
homeassistant.exceptions.InvalidStateError: Invalid state with length 289. State max length is 255 characters.

Trying to force a state and then crash maybe? Just can’t find why it does that and where.

Can you help me?

What helpers are you using?

I don’t know what to answer you. Where do you set those? That server has been running for years

Went into my automation, the only one I have is

- id: sump_pump
  alias: Sump pump
  trigger:
  - platform: state
    entity_id: binary_sensor.flood_sensor_water_leak_state
    from: '0'
    to: '1'
  condition: []
  action:
  - service: notify.alexsms
    data:
      message: Alerte du niveau d'eau
      title: Alerte sump pump
  - service: notify.alexsmtp
    data:
      message: Alerte du niveau d'eau
      title: Alerte sump pump

The error looks to be to do with a helper getting a state that is incorrect. Go to settings|devices and services|helpers. One of them seems to be screwy, it has a length of 289, whereas the max is 255. This is what I am guessing from your error message.

got onto the same issue, did you find out faulty thing?
can we turn on more logging to tell which state it is exacly?
ill let you know when i find mine…

Failed to set state, fall back to unknown
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 856, in _async_write_ha_state
    hass.states.async_set(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1645, 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 180, in validate_state
    raise InvalidStateError(
homeassistant.exceptions.InvalidStateError: Invalid state with length 716. State max length is 255 characters.

Gave a tip in the post immediately above yours.

1 Like

I removed all the helpers and it still reboots, less but reboots.

Another problem, I deleted the log file to get a new one but it didn’t recreate itself…

Still same problem, keeps on restarting. It seems to be restarting every 7 minutes

Please post your full log file to pastebin or similar.

Not much in log
https://pastebin.pl/view/6df0bfdf

Just copied, nothing in the log since this morning, but still rebooting

FWIW this “helper entity” entity.py is not the problem it’s a core “process”

So as mention by nickrout a full core-log is required, as this “initial” just saying “basically” set state = state, best would be a log with debug-level

OK, just looked briefly in posted log , start with disable your google-integration

( KeyError: ‘google_assistant’ )

Then your “Notification”
Then WLED

eventually you should be able to figure out what’s going on :slight_smile:

And “dump” your DB-file, it’s corrupt anyway

And why is your “xiaomi_gateway” not responding ? lost in your network, or new IP ?

Deleted Google Assistant, uPNP and WLED as they were giving errors. Also rename the DB file to OLD.

For the gateway I don’t know. I still can see my aqara entities but the gateway doesn’t show anymore. Used to work though

Best would be to delete/rmove ALL 3 db-files, temporary datas/transactions are stored there, and might be ingested in the new build

ok, i recently discovered that very same with my Aquara M2, actually after 2023.10.0, unfortunately it was also “gone” in my Router, so i had to re-add ( + same procedure as the very first time, if you “happens” to factory reset ! ) :slight_smile:

It just rebooted again. Deleted the three db files and restarted Home Assistant

I need to fix the reboot every 7 min before. Even by disabling all that you asked, it still reboots :frowning:

How does the logfile looks now ?

2023-10-12 15:53:11.695 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2023-10-12 15:53:23.069 ERROR (MainThread) [homeassistant.components.notify] Failed to initialize notification service nfandroidtv

2023-10-12 15:53:34.916 ERROR (SyncWorker_0) [xiaomi_gateway] Cannot connect to gateway 7c49eb1d8cc0

2023-10-12 15:53:44.929 ERROR (SyncWorker_0) [xiaomi_gateway] Cannot connect to gateway 7c49eb1d8cc0

2023-10-12 15:53:54.943 ERROR (SyncWorker_0) [xiaomi_gateway] Cannot connect to gateway 7c49eb1d8cc0

2023-10-12 15:53:58.301 WARNING (MainThread) [homeassistant.components.ps4.media_player] PS4 could not be reached

2023-10-12 15:54:04.956 ERROR (SyncWorker_0) [xiaomi_gateway] Cannot connect to gateway 7c49eb1d8cc0

2023-10-12 15:54:14.967 ERROR (SyncWorker_0) [xiaomi_gateway] Cannot connect to gateway 7c49eb1d8cc0

Ok, i assume you see what’s left to “try to do” there, and how does your other logfiles look like, i.e Host , Supervisor ?

Thou your missing gateway is hopefully your zigbee hub, it should not cause your HA to Reboot, rapidly increasing logfiles/db files will among other thigs

Also you didn’t mention whether you used the same “install-media” as you had inEpi4, ?

Another “approach” could be go further back in time, and pic a backup, prio to the time when all this started to occur

The fact that it reboots constantly at 7-8 min messed me up. When installing on the NUC, I chose a new install media. Chose Generic x86-64 for my NUC.