Read the statement by Michael Teeuw here.
MMM-Pages - Turn scripts on/off when enter page
-
Hi all,
Is it possible to start a script (Python or bash) when a specific page is entered? I use MM-Pages with a webradio on the third page. The idea is to start the webradio (mpc) combined with a script to get the lyrics of the currently played song (already developed) in case, page 3 is called. I don’t want to stress the lyrics-search if the affected page is not shown. So it would be nice have a trigger and to be able to start something on the PI.
Thank you in advance
Thomas -
Take a look at MMM-NotificationTrigger module; Im using it for a lot of things; you can trigger any shell command when something happens (ie. When entering to page x)
here just an example:
{ module: 'MMM-NotificationTrigger', config: { useWebhook: false, triggers: [ { trigger: "NEW_PAGE", triggerPayloadFilter: (payload) => { if (payload == '0') return true //when entering page 1 return false }, fires: [ { exec: "aplay /home/pi/somefile.wav" }, { fire: "MY_COMMAND", exec: "curl 'http://RaspHostname:8080/api//modules/MMM-Whatever/show'" }, { fire: "MY_COMMAND", exec: "curl 'http://RaspHostname::8080/api//modules/MMM-Whatever/hide'" }, { fire: "WHATEVER_NOTIFICATION }, { fire: "MY_COMMAND", exec: "/home/pi/somescript.sh" }, ], }, ... ...
I consider this a MUST in any Magic Mirror setup…
Can do anything you want with it :winking_face: -