How to properly "switch off"? LE10.0.2 + KODI 19.4 on RPi4B 2GB (only Wifi, no LAN) + Kore v2.5.3 + Samsung TV (with CEC)

  • Cheers,

    first timer here, have recently installed LibreELEC/KODI on my RPi4 and am having a good time, though sometimes I stumble over stuff I just don't know (like adjusting Kodis volume via my phones volume buttons).

    My question is the following: How do i shut down my TV via the Kore app without shutting down my Kodi/LibreELEC/RPi4?

    Why this matters: Currently the only ways to shutdown my TV via LibreELEC are

    - a) by issuing a CEC command on CLI, quite inconvenient.

    - b) by shutting down LibreElec/Kodi/RPi. This is not acceptable in my use case, as i am not able to Wake-On-LAN my RPi4. (Kore tries it, but to no avail as the RPi4 is only connected via WiFi)

    Also: This installation of LibreELEC only seems to allow the power mode switches "Shutdown" and "Restart" (and some very esoteric stuff). Even in "Expert" mode I am not allowed to change the "Shutdown function" in the configuration "System".

    Any tips on how I could achieve a "Shutdown TV only" power mode or a similar solution?

    P.S.: Also open to hints how to get Wake-on-Wifi working with LibreELEC. AFAIK that's just not possible with my firmware.

  • I'm about to get blasted, down-voted, and perhaps banned from the site but I connect the rPi to a switched output on the AVR.

    If I can find a better way, I will jump on it.

  • As RPi has GPIO outputs, I am using 2 different methods.

    1) relay switching the power outlet for TV, controlled by GPIO & python script, mapped to IR remote button. It can turn on / off TV. Needs a high voltage circuit building so it's dangerous for unexperienced persons.

    2) IR transmit circuit, controlled by GPIO & python script, mapped to IR remote button. It can send any IR command to TV including power on / power off. Easy to build, more universal & safe as it's only low voltage circuit. Needs an IR receive sensor as well for scanning necessary IR commands from the IR remote.

    If CEC works fine with your TV, you can also map the appropriate script to some remote button so it could be a best solution for you (don't know Kore but I suppose it could allow that).

    Edited once, last by ghtester (July 1, 2022 at 4:07 AM).

  • Cheers guys, thank you for the suggestions.

    As everything else is working fine and all the necessary technological foundations have been shown to practically work well, i would like to not tinker around with extra cables and IR remotes.

    If you could e.g. point me to the conf-files that map the powermodes to the executed commands on power switches that might allow me to fix this myself. Sadly i couldn't find that info myself.

  • Hey ghtester, thank you for the suggestions.

    1. Is about what i would like to do, i would just omit "systemctl stop kodi" of "off.sh". There's just no way i have found to issue a keystroke via Kore nor how to map this behind the buttons in the shutdown menu.

    2. Basically has the same caveat as 1. no known way to issue a keystroke via Kore.

    I have sifted a bit through the code of Kore and it seems to me that Kore just sends commands to Chorus that are defined in this file, compare:


    How I would replace one of those with the execution of a script that does something like

    kodi-send --action="PlayerControl(Stop)";echo "standby 0" | cec-client -s -d 1"

    i don't know.

  • I can't test if it works but I would try to modify the files like:

    /usr/share/kodi/addons/webinterface.default/js/kodi-webinterface.js (lines between 14172 - 14189)

    /storage/off.sh

    Bash
    #!/bin/bash
    
    kodi-send --action="PlayerControl(Stop)"   
    echo "standby 0" | cec-client -s -d 1

    Don't forget to make the script file executable:

    Code
    chmod +x /storage/off.sh
  • Thank you for the encouragement and pushing me in the right direction!

    It might be as easy as putting "System.exec" in there. For now i am not getting any further as:

    /usr/share/kodi/addons/webinterface.default/js/kodi-webinterface.js

    is on a read-only filesystem.

    Currently i am trying to find out how LibreELEC is mounting filesystems whatsoever, as fstab is empty.

    EDIT: OK, LibreELEC uses udevil, and i have seen that there are conf files and that i could mount manually, but for now i am not able to find out for this file a) on which filesystem it is and b) where that filesystem is mounted from.

    EDIT2: Ok, i have found this. Device seems to be read-write mounted, maybe the filesystem is not.

    Code
    LibreELEC:/ # udevil info /dev/disk/by-label/STORAGE
    Showing information for /org/freedesktop/UDisks/devices/mmcblk0p2
      ...
      has media:                   1
      is read only:                0
      is mounted:                  1
      mount paths:                 /storage
     ...
      label:                       STORAGE

    Maybe i there is a way to just mount this a bit differently?