Interaction between MMM-Pages & MMM-GroveGestures



  • Hi,

    I was thinking about MMM-GroveGestures to be able to send different notifications based on the MMM-Pages active page. I.e :

    When on Page 1, "CLOCKWISE " triggers "ARTICLE_NEXT"
    but
    When on Page 2, “CLOCKWISE” triggers something else…

    Do you think it’s easily doable ? Anyone interested to implement that into MMM-GroveGestures?

    Regards


  • Module Developer

    @bolish
    Interesting. Unfortunately it couldn’t at this moment.



  • @Sean
    Because technical limitations?
    I believe because it’s not possible to know which MMM-Pages is currently “active”?
    What would we need to make this possible in future?


  • Module Developer

    @bolish
    You are right. It doesn’t detect “current” page.
    Maybe I can consider “commands set” to be changed dynamically on runtime by notification.



  • @Sean

    I believe that MMM-Pages is already sending some notification “PAGE CHANGED, X”. X being the number of the active page.

    !! It even seems that MMM-pages is even able to respond to PAGE QUERY notification by sending the Page N° back into a notification!!! , look at what I found into MMM-pages :

    case 'QUERY_PAGE_NUMBER':
            this.sendNotification('PAGE_NUMBER_IS', this.curPage);
            break;
          default: // Do nothing
    

    So…if “MMM-GroveGestures” would be able to query MMM-Pages after received gesture notification and before running related action, would be perfect I guess!!

    Please forgive me if I’m totally wrong, it’ based on my “non-skilled logic”, but seems logic in my mind at least!!


  • Module Developer

    @bolish
    Good suggestion. The only thing I aware is I don’t want to make a module dependent with specific module directly in its code.
    So I’m considering commands set which could be selected by notification(even from MMM-Pages) on runtime if it needs. I think it could be used for your case.



  • @Sean agree to avoid dependencies.
    Commands set & runtime is far over my skills level (for now at least, maybe I will dig in javascript in future).
    Anyway, anything you need from me, such as testing, let me know!

    Appreciate your support if you could give some of your time to this idea.


  • Module Developer

    @bolish I’ve updated.



  • @Sean you’re fast.
    I’ve made several trials, everything seems to work perfectly with your new code. You rock.

    Nevertheless, I’m facing an issue…I believe it’s because I’m not able to write the payload thing right…Would you mind having a look :

    commandSetTrigger: {
    					  "TESTESTT": "0",
    					  "DEFAULT_MODE": "DEFAULT_MODE",
      					  "PAGE_NUMBER_IS": (payload) => { // You can use callback function to change set with conditional payload values.
    									    return payload.commandSetName
    											  }
    					},
    

    At one moment in time, I’m receiving “PAGE_NUMBER_IS” with payload=X.
    I’ve a commandset called “X”, but it’s not working…

    I’ve tried to send “PAGE_NUMBER_IS” + payload “X” manually = your code works fine. So no issue there.
    I’ve installed a notification reader = i’m sure I’m receiving the “PAGE_NUMBER_IS” notification. So that’s fine also.

    The only thing I maybe don’t know is what payload “X” (0 or 1 or 2 or 3) is included in the notification I’m receiving. I tried to transform this notification+payload into an alert+payload (through MMM-notification trigger) to check what the “X” payload is…But I also failed to do that because you need to deal with payload/return which I don’t know…
    Nevertheless, I’m quiet convinced X=0 because it’s how the MMM-PAGES works.

    Anyway, I’m stucked and I believe it’s because I’m writting the payload thing wrong.

    Would appreciate your support there.


  • Module Developer

    @bolish
    Try this.

    "PAGE_NUMBER_IS": (payload) => { return payload }