WTH why do we need to restart HA core so much?

When you reload automations any currently running automations are stopped. Specifically that means delays, wait steps and for x time options in triggers/conditions will be cut short. Same with scripts.

For all entities the other consequence is history. When you reload an integration then all entities made by that integration go to state unavailable then (sometimes, depends on the integration) unknown and then finally back to the state they are supposed to be in. These changes triggers state changes if any automations are watching them and updates the last_changed and last_updated values of these entities.

If you’re fine with all that then no, there’s no consequences. I generally prefer to reload no more then necessary.

2 Likes

We have to restart several times a day just to refresh Lifx Scenes. We have to restart every time we add something from HACS. 'nuf said.

1 Like

Update few days and HA restarts later @petro regarding WTH why do we need to restart HA core so much? - #20 by e-raser:

Unfortunately when setting a unique_id for (command_line) sensors after using them already, it seems one ends up with a lost history from before that change.

  • An entity now having a unique_id can not be mapped to the former one with the same name but without the unique_id.
  • Probably “works as intended” but a big downside for me as I use some sensors for long term statistics - which are now gone (no matching in HA recorder database) :frowning:

Random example below (added unique_id at October 1st 00:27:57 for this entity):

:arrow_right: In case there’s a trick to merge the database entries of the former “unique_id-less” entities with the newer ones now being unique… please let me now!

1 Like

that sounds like a problem with Lifx not HA.

Right. Because HA has to incorporate the new code into the system.

without that then HA has no idea it even exists until it reads in and initializes all the new custom things.

I dfoubt there’s anything HA can really do about either of those in regard to restarts.

1 Like

the database has no link to unique_id, it’s entity_id driven. Remove the old entity_id, restart, rename the new unqiue_id driven entity_id to the old entity_id, done.

1 Like

That’s what I did. Please note:

  1. I got plenty of “_2” entities (the former shadow entities), without having the “normal” ones. So I renamed those “_2” entities, e. g. “sensor.cpu_clock_2” now is “sensor.cpu_clock”. I think that might be the actual reason. Root issue: why there were only the “_2” entities after adding unique_id’s and reloading the sensors.
  2. I think another “logical miracle” additionally kicked in here: HA was running for longer (18 days) than the recorder “purge_keep_days” setting (14 days) which is why there were no states for many entities (because of a lack of entity value updates during the last 14 days).

Pretty complicated, don’t think I can get the history back (without needing to fiddle around directly in the database which is what I hate and for that reason there’s Fix Individual Entity Data Points and similar).
Lesson learned (the hard way, by loosing plenty of history): always add a unique_id right from the beginning when creating a new sensor. Saves tons of time…

Now I reload much often because the OS reminds me and does it almost automatically. I have screenshot from last year. Is this issue still valid? Then it should have its own WTH.

Integrations in need of reload capabilities (and other modernization): Alerts, history stats, utility meter, logging

Edit: And of course recorder - WTF there's no option to reload recorder configuration from the UI/without a restart

1 Like

All SNMP sensors, switches etc need restart ):

18/25 of the integrations I use in the UI have the reload option… Of those very few of them ever seem to actually get fixed or update from issuing the reload… Most of the time I end up having to reboot HA even though the problem seems to be a DSM device not showing up or a HomeKit device acting up etc.

So ya, need to restart all of HA OFTEN.

1 Like

HA not, devs can. but likely doesn’t care.

HA is built in a way that all modules are part of single runtime. When HA core starts all its modules are being included and started too.

HACS and its custom components ‘pretend’ to be just another modules of HA. Which obviously require restart of HA to be run.

But it’s not true modules couldn’t be initialized independently, added during HA runtime etc. But it requires programming effort (and likely strategic decisions of HA owners prior to that).

As long as HA is a monolith it will require restart to run its modules. Vote for changing HA architecture in WTH

2 Likes

@frenck I do think it is possible to add options to update custom integrations without the need to restart core:

  1. Update - Unload the entries created by the integration (same as the existing implementation) and reload the integration (similar to what happens when a user adds an integration), of course this relies on the integration to unload correctly, but is possible.
  2. Remove - Just unload (user needs to delete the files after or it will be reloaded after restart)
  3. Add : two options:
    a. Add button to rescan custom integrations and load newer integrations
    b. When user clicks on the “Add integration” button, rescan custom integration folders and load new integrations
1 Like

If I want to change logging levels, to temporarily investigate something, two HA restarts are needed last I checked, (The 2nd one is need3d to turn logging back down).

no, you can change logging levels with a service.

2 Likes

Thanks - I hadn’t seen that. There is documentation, like the MQTT logging page, that only show changing logging via configuration entries. MQTT Logging - Home Assistant

(Note the MQTT logging page is linked from the list of topics on the right hand side of all docs pages, so it isn’t exactly an obscure documentation reference.)

home assistant docs are separated per integration. If you want to read up on logger functionality, you go to the logger integration docs, not the MQTT integrations docs.

Totally correct. That being said, this is kinda a WTH IMO. Debug logging is a handy tool to have in your toolkit when facing issues and it currently requires a lot of insider knowledge to turn it on.

I made a separate WTH about this @rct . It’s not a restart issue so it’s off topic here but I agree it is unnecessarily confusing.

1 Like

This doesn’t seem to work for me. Don’t know if it is a bug in 2022.9.x.

Was logger been added to default_config or is the need to add it to your config missing from Logger - Home Assistant ?

In any case for me it appears logging level changes still requires an HA restart for me.

You have to have logger: in configuration.yaml

I was going to mention that, this is the only drawback and not so clear in the docs that you need to do it for the services to work, when I ask people for logs I do ask them to add the loggers to configuration.yaml and restart core mainly because I don’t know if they have it already.
I wonder if we can convert the logger to config flow so it would be possible just to add it and maybe even select components from the UI… I will try to discuss it with other members.

1 Like