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 853 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.
    • thgmirrorT Offline
      thgmirror
      last edited by thgmirror

      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
      • rubenixR Offline
        rubenix
        last edited by rubenix

        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
        • thgmirrorT Offline
          thgmirror
          last edited by

          Hi @rubenix ,

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

          Greetings
          Thomas

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            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