How to catch and interpret CEC signal from TV @LibreELEC

  • Didnt find anything in this thread yet, so I wonder, if following workaround is doable:


    Add option to shutdown/startup kodi service (systemctl) to the usual Sleep/Hibernate functions. So it could be assign for example to CEC TV turn on/off actions. Or additionaly also by keypress through lirc/remote?


    Not sure if this is possible (especially turn-on) part, ie. if using Lirc/remote.xml (maybe lircd) need kodi service running to process keypress. And the same thing for CEC..


    Is this total nonsense, or something, what could be done?

    6x Odroid C2 + CoreELEC 9.0.1; 6x RPi2 + LibreELEC 9.0.1; 3x Win7 Kodi 18.1 + vPeter's mariaDB plugin as Library DB

    Edited once, last by JimmySmith ().

  • JimmySmith

    Changed the title of the thread from “Shutdown kodi service instead Sleep” to “Systemctl kodi service as action, beside Sleep, Hibernate...”.
  • For IR you can use irexec.

    For keyboard I was using actkbd to restart kodi when kodi become non-responsive. (Gladly it is not needed anymore for last few months.)

    No idea for CEC (only tested few times).

    Done giving support here because of last events.

  • Thanks.. That sounds promising and propably deserves some digging :)


    Triggering events manually (need to use two more buttons, but better than 20% CPU all the time)

    Keyboard input

    I dont use keyboard anywhere, from the quick google seems that actkbd would must be ported.


    IR remoted environments looks easy:

    Create /storage/.config/lircrc

    Code
    1. begin
    2. prog = irexec
    3. button = KEY_UP
    4. config = systemctl start kodi
    5. end
    6. begin
    7. prog = irexec
    8. button = KEY_DOWN
    9. config = systemctl stop kodi
    10. end


    lircrc deamon isnt started in LE automatically, when lircrc is present, so we need to start it via autostart.sh / etc

    irexec -d /storage/.config/lircrc


    CEC-related inputs:

    I think libCEC should handle inputs even when Kodi service is down - otherwise I dont know, how would be possible to wakeup sleep/hibernated device through it. How to catch input and execute command is another thing.. I look on the Input-libCEC settings, but I dont see there CEC related option, how to "wake-up" Kodi box, when TV is turned ON. Correct me please, if I am mistaken.



    Next big question is, if this could be

    Automated solution

    Shutdown Kodi - I can imagine grep kodi.log, to find, if there is inactivity, or use some Addon (1 / 2) to trigger stop action instead screensaver etc.

    Startup Kodi - Here is really troublemaker. Only thing I imagine there is CEC environments, so Kodi would be started (ie. script would be called) when connected TV is turned ON. But here I am struggling still. How to catch and interprete CEC command: outside Kodi, but just on Linux LibreELEC level?

    6x Odroid C2 + CoreELEC 9.0.1; 6x RPi2 + LibreELEC 9.0.1; 3x Win7 Kodi 18.1 + vPeter's mariaDB plugin as Library DB

    Edited 7 times, last by JimmySmith ().

  • JimmySmith

    Changed the title of the thread from “Systemctl kodi service as action, beside Sleep, Hibernate...” to “How to catch and interpret CEC signal from TV @LibreELEC”.