My little hyperion helper

So made this for shit and giggles a script that you move to /etc/cron.hourly that checks if the hyperion is running after 22 and turns it off then turns it back on at 8 along with rpi leds.

Kinda my solution to get all the blinking lights turned off at a certain time :slight_smile:

#!/bin/bash
# version 3
hyperion_helper () {
if [ "$(date +"%H")" -ge "07" ]
then if [ "$(date +"%H")" -gt "21" ]; then hyperion_service_check_disabled; exit 1; fi
        hyperion_service_check_enabled
else if [ "$(date +"%H")" -lt "08" ]; then hyperion_service_check_disabled; fi
fi
}

hyperion_service_check_disabled () {
if [ "$(systemctl is-active hyperion.service)" = "active" ]
  then sudo service hyperion stop
    if [ $(cat /sys/class/leds/led0/brightness) -ge 1 ]; then sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness'; fi
    if [ $(cat /sys/class/leds/led0/brightness) -ge 1 ]; then sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness'; fi
    if [ $(which llctl | wc -l) -eq 1 ]; then sudo llctl f0 l0 d0; fi
       kodi-send --action="Notification(Hyperion Service,Lights will turn off now,1500)"
fi
}

hyperion_service_check_enabled () {
if [ "$(systemctl is-active hyperion.service)" = "failed" ] || [ "$(systemctl is-active hyperion.service)" = "inactive" ]
  then sudo service hyperion start
  if [ $(cat /sys/class/leds/led0/brightness) -eq 0 ]; then sudo sh -c 'echo 1 > /sys/class/leds/led0/brightness'; fi
  if [ $(cat /sys/class/leds/led0/brightness) -eq 0 ]; then sudo sh -c 'echo 1 > /sys/class/leds/led1/brightness'; fi
  if [ $(which llctl | wc -l) -eq 1 ]; then sudo llctl f1 l1 d1; fi
       kodi-send --action="Notification(Hyperion Service,Lights will turn on now,1500)" 
fi
}

hyperion_helper
3 Likes

updated the script above to turn off even more leds at night

added llctl if its running on raspberry and fixed a couple of bugs