• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

MMM-Pages - Turn scripts on/off when enter page

Scheduled Pinned Locked Moved Development
3 Posts 2 Posters 532 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    thgmirror
    last edited by thgmirror Jun 12, 2020, 12:09 PM Jun 12, 2020, 12:09 PM

    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

    1 Reply Last reply Reply Quote 0
    • R Offline
      rubenix
      last edited by rubenix Jun 12, 2020, 2:51 PM Jun 12, 2020, 2:49 PM

      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:

      1 Reply Last reply Reply Quote 0
      • T Offline
        thgmirror
        last edited by Jun 12, 2020, 2:54 PM

        Hi @rubenix ,

        Thank you for your hint, I will give it a try.

        Greetings
        Thomas

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy