[How to do instruction] Automatic power on/off active speakers with connected power plug / IFTTT - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9) +--- Thread: [How to do instruction] Automatic power on/off active speakers with connected power plug / IFTTT (/showthread.php?tid=2935) |
Automatic power on/off active speakers with connected power plug / IFTTT - lelobster - 09-03-2020 Hi, As my speakers and sub have a big electric consumption and because I wanted something more fluid, I manage to power them automatically if mpd/renderers are playing, also it's powered off after x minutes of audio inactivity. I used a connected (wifi) power plug, ifttt, and the code is inspired by original moodeaudio watchdog.sh script. 1. ifttt config - Get a connected power plug compatible with ifttt (any model should work mine is the tp-link hs100) - Give power plug access to ifttt (search for the right service, for me it was kasa) - Install webhooks service on ifttt - Create 2 applets on ifttt: IF "webhooks event power-on" THEN "turn on power plug" IF "webhooks event power-off" THEN "turn off power plug" - Go to webhooks documentation or (settings) on ifttt and copy/paste your personnal key somewhere 2. Get your rpi ready to power on/off your speakers ssh your pi and with the code below, create these 4 files: /home/pi/ifttt_on.py Code: #!/usr/bin/python Code: #!/usr/bin/python /home/pi/watchdog-speakers-on.sh Code: #!/bin/bash Code: #!/bin/bash - Edit the card# according to your setup if it's not card0 - Edit the time you want the rpi to wait before power off speakers in watchdog-speakers-off.sh where there is "sleep 500" (meaning x seconds before power off, here 500) - Make the 4 files executable "chmod +x /home/pi/all4files" add to rc.local for execute script on boot Add these 3 lines at the end of /etc/rc.local but before last line "exit 0" Code: # Power plug management 3. Reboot and enjoy RE: Automatic power on/off active speakers with connected power plug / IFTTT - TookaFace - 09-12-2020 Very nice stuff RE: Automatic power on/off active speakers with connected power plug / IFTTT - Daksha - 04-21-2021 GREAT STUFF! This is gonna make me use Moode as alarm clock! Thanks a loooot! RE: Automatic power on/off active speakers with connected power plug / IFTTT - chutiloco - 05-05-2021 Fantastic!!! Work like a charm. Very clear, organize, easy to understand and elegant code. Thanks, thanks, thanks!!! RE: Automatic power on/off active speakers with connected power plug / IFTTT - lelobster - 06-08-2021 (05-05-2021, 09:25 PM)chutiloco Wrote: Fantastic!!! Thanks for feedback! RE: Automatic power on/off active speakers with connected power plug / IFTTT - Daksha - 09-25-2021 It would be nice and very useful to have a version of the "watchdog-speakers-on.sh" script to check for alarm-clock events instead of sound device state, but sadly I've no skill to do this... RE: Automatic power on/off active speakers with connected power plug / IFTTT - lelobster - 09-26-2021 (09-25-2021, 05:41 AM)Daksha Wrote: It would be nice and very useful to have a version of the "watchdog-speakers-on.sh" script to check for alarm-clock events instead of sound device state, but sadly I've no skill to do this... hey, the script is powering up plug on alarm clocks already, I m not sure i follow your suggestion. RE: Automatic power on/off active speakers with connected power plug / IFTTT - Daksha - 09-27-2021 (09-26-2021, 10:04 PM)lelobster Wrote:(09-25-2021, 05:41 AM)Daksha Wrote: It would be nice and very useful to have a version of the "watchdog-speakers-on.sh" script to check for alarm-clock events instead of sound device state, but sadly I've no skill to do this... The current script powers up on soundcard activity. It fires speakers on whenever music plays, than of course, even on alarm clock events. My suggestion (but I don't know if this is possible) was to have a script reacting to just the alarm event instead of soundcard state: this would be useful, for instance, to switch on speakers and lights too, every morning (but not every time music plays) |