1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Restart Hyperion.NG on plug in the USB grabber

Discussion in 'Hyperion General' started by wladi, 22 December 2020.

  1. wladi

    wladi Member

    Messages:
    36
    Hardware:
    RPi3
    Maybe will be useful for someone:

    System: Hyperion.NG running on Raspberry Pi 3 b+, Raspbian OS, USB capture device
    Problem: if USB graber is plugged off and then again plugged in, then the hyperion does not get video signal and ambilight does not work.
    Solution Idea: restart aitomatically hyperion service if USB graber plugged in. Use udev for that...
    Solution implementation:
    1) Make new udev rule:
    1.1) Execute command:
    Code:
    sudo nano /etc/udev/rules.d/99-USBVideo.rules
    1.2) In the nano editor insert the rule line like this (eventually you need to change the device name /dev/video0):
    Code:
    ACTION=="add", SUBSYSTEMS=="usb", ENV{DEVNAME}=="/dev/video0", RUN+="/bin/sh -c 'sudo systemctl restart [email protected]'"
    1.3) Use Ctrl+X, Y, Enter to save and exit the editor
    2) Reload rules using command:
    Code:
    sudo udevadm control --reload-rules && sudo udevadm trigger
    If something doies not work, an additional RUN can be added to the rule line to check if it is executed on plug:
    Code:
    RUN+="/bin/sh -c 'echo $(date) $(env) >>/tmp/udev-debug.log'"
    In this case the whole rule is like this:
    Code:
    ACTION=="add", SUBSYSTEMS=="usb", ENV{DEVNAME}=="/dev/video0", RUN+="/bin/sh -c 'sudo systemctl restart [email protected]'", RUN+="/bin/sh -c 'echo $(date) $(env) >>/tmp/udev-debug.log'"
    Each time the rule triggers, a new line will be added to the file /tmp/udev-debug.log. You can read this file to check if the rule has triggered.

    Hyperion can also be stopped if usb grabber is unplugged, it reduces prozessor load. For that add second line to the USB-video.rules file:
    Code:
    ACTION=="remove", SUBSYSTEMS=="usb", ENV{DEVNAME}=="/dev/video0", RUN+="/bin/sh -c 'sudo systemctl stop [email protected]'"


     
    Last edited: 2 January 2021
    • Like Like x 1