MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

Hide Rain-Modul with MMM-Alexa-Control and MMM-Remote-Control



  • Hello
    I have a question about the Alexa Control Module:
    I am using the remote module and the Alexa control module.
    I would like to show the RainRadar module and hide what works with the remote module.
    There is a code in the rain module

    
    ///// Add this function to the modules you want to control with voice //////
    
    notificationReceived: function (notification, payload) {
    if (notification === 'HIDE_RADAR') {
    this.hide (1000);
    } else if (notification === 'SHOW_RADAR') {
    this.show (1000);
    }
    
    },
    
    })
    
    
    

    I would like to know where to insert this code in the config
    and whether I can take it over because of the syntax

    I would be grateful for help



  • @radioman you would have to make a custom device with your action



  • I don’t know what you mean by costum device
    Can you give me a code example or can I do it like that

    notifications: [
        {
            name: 'Notification 2',
            port: 11101,
            OnOff: true,
            notification: [["NOTIFICATION ON", "PAYLOAD ON"],["NOTIFICATION OFF", "PAYLOAD OFF"]]
        }
    ]
    

    Then the question what does a notification and a payload look like in my case

    I got this example from the Githup Homepage with the MMM-Alexa control module



  • @radioman you didn’t read the rest

    Notification devices
    Notification devices allows you to send notifications to other modules.
    You can send the same notification when you turn the device on and off like this:
    Note: You have to put the notifications array you chose inside the config part.
    
    notifications: [
        {
            name: 'Notificaition 1',
            port: 11100,
            OnOff: false,
            notification: ["NOTIFICATION", "PAYLOAD"]
        }
    ]
    You can send different notifications when you turn a device on or off like this:
    
    notifications: [
        {
            name: 'Notification 2',
            port: 11101,
            OnOff: true,
            notification: [["NOTIFICATION ON", "PAYLOAD ON"],["NOTIFICATION OFF", "PAYLOAD OFF"]]
        }
    ]
    Note: NOTIFICATION ON and NOTIFICATION OFF stay for the different notifications you can send when you turn on or off the device. The same thing applies to PAYLOAD ON and PAYLOAD OFF.
    
    These are the configuration options for a notification device:  / < ===================================
    Note: They are all necessary.
    
    Option	Description
    name	Here you can name your device. Make sure you didn't used the name before. Delete first the old device.
    port	Here you can give the device a static Port. I suggest that to you because then there aren't overlaps. Preferably start with the port 11100.
    OnOff	If you want to send the same notification when you turn a device on and off chose true. Otherwise if you want to send different notifications chose false.
    Possible values: true and false
    notification	If OnOff is true:
    notification: [["NOTIFICATION ON","PAYLOAD"],["NOTIFICATION OFF", "PAYLOAD"]]
    Replace the notifications and the payloads.
    If OnOff is false:
    notification: ["NOTIFICATION", "PAYLOAD"]
    Replace the notification and payload.
    

    further down there is a Command Device
    and beyond that is Custom Device



  • @radioman

    and he provided a sample for a notification device in the config section of the module def

    notifications: [
        {
            name: 'Notification 2',
            port: 11101,
            OnOff: true,
            notification: [["NOTIFICATION ON", "PAYLOAD ON"],["NOTIFICATION OFF", "PAYLOAD OFF"]]
        }
    

    so a sample config with this

    
    		{
    			module: "MMM-AlexaControl",
    			disabled: false,
    			position: "bottom_left",
    			config: {
    				deviceName: "desk",
    				image: false,
    				pm2ProcessName: "MagicMirror",
    				vcgencmd: "hide",
    				monitorToggle: true,
    				startPort: 16000,
    				reboot: true,
    				shutdown: true,
    				stop: true,
                                    notifications: [
                                                   {
                                                       name: 'Notification 2',
                                                       port: 11101,
                                                       OnOff: true,
                                                       notification: [["NOTIFICATION ON", "PAYLOAD ON"],["NOTIFICATION OFF", "PAYLOAD OFF"]]
                                                       }
                                   ]
    			},
    		},
    

    and u have

    if (notification === 'HIDE_RADAR') {
    this.hide (1000);
    } else if (notification === 'SHOW_RADAR') {
    this.show (1000);
    

    remember this is a dumb electric outlet, on or off, what do you want to send when?

    so I assume as u have no payload check
    on = HIDE_RADAR, and off means SHOW_RADAR

     notification: [["HIDE_RADAR", null],["SHOW_RADAR", null]]
    


  • Ok, I have now entered that

    {
                module: 'MMM-AlexaControl',
                position: 'bottom_left',
                config:{
                    image: false,
                    pm2ProcessName: "mm",
                    refresh: true,
                    restart: true,
                    reboot: false,
                    monitorToggle: true,
                    vcgencmd: 'vcgencmd',
                    deviceName: "Spiegel",
                    startPort: 12000,
                       notifications: [
        {
            name: 'Radar',
            port: 12101,
            OnOff: true,
            notification: [["NOTIFICATION ON", "SHOW_RADAR"],["NOTIFICATION OFF", "HIDE_RADAR"]]
        }
    ]
              
             }
            },	
    
    

    Alexa also finds a device but I can’t control it
    What would I have to enter with notificaton and with Payload

    Or am I not allowed to change the payload



  • @radioman I gave u the sample above w your notification!?

    and you say Alexa turn off Radar, or Alexa turn on Radar

    it’s an outlet device on or off



  • OK
    I read your post again carefully and have now understood it
    and it works.
    Many thanks


Log in to reply