Chromium kiosk mode: show home assistant

I’m trying to auto launch dietpi with a home assistant gui on a hdmi display. So, I sucessfully installed and configured chromium browser in kiosk mode. It loads fine the URL I configure in dietpi.txt: http://localhost:8123 (home assistant web interface) - I had to add the protocol to make it work.
The problem ist, chromium seems to load faster that even the barest home assistant necessity, which leads to a page load error. After some wating and pressing reload, it loads fine.
Sometimes it works. So it seems to be a kind of race between home assistant and chromium, they alternate in “winning”.
What can be done about this? I thought of giving a javascript page instead, which in the background checks for localhost:8123 and makes a redirection if avaliable. But it’s quite working on the symptoms instead of on the sickness itself.
Is there a smarter way of making chromium wait for home assistant? Or let dietpi wait before starting chromium. Maybe inside the systemd service units?

So, I put a sleep 10 to the beginning of /var/lib/dietpi/dietpi-software/installed/ This is a functioning workaround, which confirms for me the race theory.

I like the idea of using systemd for resolving this race. This leads me to the question: who/what is starting /var/lib/dietpi/dietpi-software/installed/ Is it a systemd unit already?

It think it#s called from /boot/dietpi/dietpi-login when you set in dietpi-autostart that chromium should automatically start:

# Chromium
		elif (( $auto_start_index == 11 )); then

			exec /var/lib/dietpi/dietpi-software/installed/

I don’t think there is a systemd service for chomium, it just executes the binary. This is just a bash script. On boot it runs dietpi-login and bc you have installed chromium and the autostart option is set, it execs this bash script.
Your modification should survive udpates of chromium, but not if you reinstall it via dietpi-software.

Ok, thanks, so no systemd involved at the moment.
Remains the question for the developers: Any suggestion, what’s a good, clean way of letting chromium kiosk wait for the home assistens web service to have started?

I am not sure if there is a clean way. But you could change the autostart option to a custom script and create your own script that checks HA availability and then starts the kiosk.

Ok. That’s similar to what I’ve done: changed the dietpi-autoscript itself. Any problem with this? Probably that my changes get overwritten by an update?
You suggestion is good, but not much “clearer” that the javascript idea from the original posting, is it?

Normally, client settings should not be overwritten. But if you switch them on or off, the default settings could be set. Therefore, the custom script might be the better way.

But what you define as “clean” is up to you. Whatever you do, it remains a custom function. :wink:

check with curl if the site is already ready, and if not, pause and do the check again.
if the check succeeds, start chromium
curl -Is http://loaclhost:8123 | head -n 1 will return something like HTTP/1.1 200 OK.
something like: (not tested)


# URL which should be checked

# number of tries

# pause between checks, if check fails

# actual loop
for ((attempt = 1; attempt <= max_attempts; attempt++)); do
    response=$(curl -Is "$url" | head -n 1)
    # check response
    if [[ "$response" == *"200 OK"* ]]; then
        <here your command to start chromium> (chromium-browser "$url" argument_for_kiost etc...)
        exit 0
        sleep $retry_interval

echo "home assistant not available"
exit 1

1 Like

Thank You very much. Thanks also for the script, that’s around how I’d had done it too (if not by javascript). So, I’ll go that way.