[SOLVED] Shell Command starting Chromium doesn't work

Hey,

I want to create an automation, which turns on the Monitor attached to the RaspberryPi running Hass and shows a webpage.

The Switch turning the Monitor on and off works and also the corresponding automation, excpet one little part.

- service: shell_command.start_chromium_poster

The command is defined as follows:

shell_command:
  start_chromium: 'chromium-browser --kiosk --incognito "http://localhost:8123/local/test.html"'

If I execute that command right in the terminal (not ssh) everything works.

Can someone tell me, what am I doing wrong?

Solved it! :smirk:

I just needed to add something:

 start_chromium: 'DISPLAY=":0.0" chromium-browser --kiosk --incognito "http://localhost:8123/local/test.html"'
1 Like

I cannot get this to work, my home assistant is running on a Debian Pi in a virtual environment.

pi@raspberrypi:~ $ sudo -u homeassistant -H -s
homeassistant@raspberrypi:/home/pi $ source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@raspberrypi:/home/pi $ chromium-browser
 --disable-quic --enable-tcp-fast-open --disable-gpu-compositing --ppapi-flash-p                                                  ath=/usr/lib/chromium-browser/libpepflashplayer.so --ppapi-flash-args=enable_sta                                                  gevideo_auto=0 --ppapi-flash-version=
[1039:1039:1227/112335.331905:ERROR:browser_main_loop.cc(670)] Failed to put Xli                                                  b into threaded mode.

(chromium-browser:1039): Gtk-WARNING **: cannot open display:

Trying β€œDISPLAY=”:0.0" chromium-browser" results in " Gtk-WARNING **: cannot open display: :0.0"

I found a fix, as the user logged into the pi locally (and connected to a display via HDMI) is β€œpi” and hass is running as a non-graphical user, you have to state the user to run the program as, using " sudo -u pi":

pi@raspberrypi:~ $ sudo -u homeassistant -H -s
homeassistant@raspberrypi:/home/pi $ source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@raspberrypi:/home/pi $ sudo -u pi DISPLAY=β€œ:0.0” chromium-browser