HA cannot be restarted from UI

Hi,

DietPi version
G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=0
G_DIETPI_VERSION_RC=2
G_GITBRANCH=‘master’
G_GITOWNER=‘MichaIng’

Distro version
bullseye 0

Kernel version
Linux DietPi 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64 GNU/Linux

SBC model
RPi 4 Model B (aarch64)

There appears to be a breaking change in HA 2022.2.2 which I did not spot before:

Home Assistant no longer supports managing a PID file or creation of a daemon process. > Users who use a customized core or container installation may need to update their startup scripts.

The --runner option is no longer supported by the hass command. Requesting a restart from the UI will now always exit with exit code 100. You will need to update your startup scripts to handle the restart, like our Systemd service example.

Home Assistant will exit immediately if not started from a supported operating system according to ADR-0016: Linux (including WSL) or OSX. A new command line parameter --ignore-os-check has been added to allow overriding this check.

(@emontnemery - #64345) #64347) #64352)

ok I had a look and you could create an ugly workaround, to restart service as soon as failed. This is basically what the restart button does, killing the process.

Feb 05 12:57:15 DietPi4 systemd[1]: home-assistant.service: Main process exited, code=exited, status=100/n/a
Feb 05 12:57:15 DietPi4 systemd[1]: home-assistant.service: Failed with result 'exit-code'.
Feb 05 12:57:15 DietPi4 systemd[1]: home-assistant.service: Consumed 8min 33.187s CPU time.

You can do it on a drop-in config for home-assistant.service as follow.

nano /etc/systemd/system/home-assistant.service.d/dietpi-services_edit.conf

and add

[Unit]
StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Restart=always
RestartSec=5s

once done

systemctl daemon-reload
systemctl restart home-assistant.service

The other error messages are related to the device you like to connect. On my test system, I could force the error message related to FFmpeg by including some Nest Protect device who seems to require this module. You could worked around by installing the require module

dietpi-software install 7

Here it is: https://github.com/home-assistant/core/issues/65450
Hence:

echo -e '[Service]\nRestartForceExitStatus=100' > /etc/systemd/system/home-assistant.service.d/dietpi-services_edit.conf
systemctl daemon-reload
systemctl restart home-assistent

I’ll add it to dietpi-software as well.

Means my workaround would not be needed in this case, right?

Jep, this RestartForceExitStatus is actually an elegant way to better achieve this, triggering only at the one intended exit code that is returned when HA forks a child and terminates, to restart.

Fixed with: https://github.com/MichaIng/DietPi/commit/1df9643

sorry - been out.

Are you saying that I should upgrade to DietPi 8.1 Beta and, separately, install #7 for the ffmpeg issue?

Simply run:

rm /etc/systemd/system/home-assistant.service.d/dietpi-services_edit.conf
G_CONFIG_INJECT 'RestartForceExitStatus=100' 'RestartForceExitStatus=100' /etc/systemd/system/home-assistant.service '\[Service\]'
systemctl daemon-reload
systemctl restart home-assistent

Are you saying that I should upgrade to DietPi 8.1 Beta

DietPi v8.1 will be released this weekend. The fix has not been applied to Beta brach so far. I guess it will pushed to Beta short before release only. Therefore you can wait until release or use the workaround provided by MichaIng

separately, install #7 for the ffmpeg issue?

yes.

thanks so much for your help!

thanks!

I get no such file or directory with the first line rm /etc/systemd/system/home-assistant.service.d/dietpi-services_edit.conf

that’s fine. The file did not exist so far. No issue, it was just to remove if available.

awesome - can confirm that this works :smiley:

fix has been released on DietPi 8.1

nice!