Strange problem with executeCommandLine in Rule

  • Platform information:
    • Hardware: Intel NUC
    • OS: Ubuntu 20.04 LTS
    • Java Runtime Environment: Environment Zulu11.54+25-CA (build 11.0.14.1+1-LTS)
    • openHAB version: 3.2.0 (apt installation)
  • Issue of the topic:

I use “executeCommandLine” calls in two rules with “sudo” to stop and start a local kodi installation on my Intel NUC (=openhab and kodi are running on the same machine).

When issuing “sudo systemctl restart kodi” as user “openhab” on a commandline by itself, everything works as expected. This is, when calling “sudo systemctl stop kodi-gbm”, kodi stops as expected and when calling “sudo systemctl restart kodi-gbm” kodi starts and you can see it’s GUI on the display attached to the HDMI port of the Intel NUC.

When using this “executeCommandLine” call in a rule:

executeCommandLine(“sudo”,“systemctl”,“stop”,“kodi-gbm”)

Kodi stops as expected and everything is fine. The issue is, when using this call:

executeCommandLine(“sudo”,“systemctl”,“restart”,“kodi-gbm”)

Kodi starts as expected, but the display stays black and shows no output. In Kodi’s logfile i can see this happening:

Logentries of Kodi, when using sudo in an interactive commandline session:

   INFO <general>: Found 1 Lists of Devices
   INFO <general>: Enumerated ALSA devices:
   INFO <general>:     Device 1
   INFO <general>:         m_deviceName      : hdmi:CARD=HDMI,DEV=0
   INFO <general>:         m_displayName     : HDA Intel
   INFO <general>:         m_displayNameExtra: BNQ BenQ GL2450H on HDMI #0
   INFO <general>:         m_deviceType      : AE_DEVTYPE_HDMI

Logentries of Kodi, when started by executeCommandline:

   INFO <general>: Found 1 Lists of Devices
   INFO <general>: Enumerated ALSA devices:
   INFO <general>:     Device 1
   INFO <general>:         m_deviceName      : hdmi:CARD=HDMI,DEV=0
   INFO <general>:         m_displayName     : HDA Intel
   INFO <general>:         m_displayNameExtra: HDMI #0
   INFO <general>:         m_deviceType      : AE_DEVTYPE_HDMI

Notice the difference in the “m_displayNameExtra” fields.

There are a lot more entries in the logfile of both calls, which show, that in the first case Kodi is happy with the hardware it detected and in the second case it is not. Since both logfiles are rather long, i have cut out those lines which (from my point of view) contain the cause of the problem. If more logging context is needed/helpful, i can post the complete version of both logfiles.

So there seems to be some kind of difference in the way sudo, systemctl and/or Kodi behave when started manually on the commandline or by using “executeCommandLine”, but until now i’ve been unsuccessful in finding the cause of this. I’m not even sure, if this is an openhab, sudo, systemctl or Kodi issue. Any ideas on this?