Notifications and commands help please.



  • Hi all, I’m new here so be gentle. I’m by no means a coder or anything like that, however with plenty of tutorials and this awesome forum I’ve managed to get the majority of my mirror set up how I like it. My question is the notification system:

    I’m using pikrellcam to look after the camera on my Pi3, this can receive commands:

    echo "motion_enable on" > ~/pikrellcam/www/FIFO
    echo "motion_enable off" > ~/pikrellcam/www/FIFO
    

    My idea is to use MMM-NetworkScanner to ping my mobile, then broadcast the relevant command
    i.e. if I’m at home - turn motion detect off, when I go out - turn motion detect on.

    I can get it to ping my phone, and broadcast notifications, but I have no idea how to get it to issue commands - any ideas?

    Am I even going about this the right way?

    Thanks in advance, Jon.



  • as part of the configuration file for MMM-NetworkScanner there is an “occupiedCMD” and “vacantCMD” that you could try setting with the command sequence above. I haven’t used this tool yet so I am unsure what sort of commands can be passed.



  • @Privacywonk Thanks for your idea, tried it today and it just comes up with ‘Please create a config file’.
    I tried putting the command inside { }, " ", and ’ '.

    Any other ideas?



  • So I did some quick googling over coffee this morning. I think there is a two part suggestion for you. Please note, this will require research and testing which I have not done, this is just directional.

    1. Install MMM-RemoteControl - https://github.com/Jopyth/MMM-Remote-Control
    2. Add some custom code to the MMM-Remote-Control module to handle requests for turning on/off the motion device.

    In MMM-Remote-Control’s node_helper.js module, you can find the “MONITORON” code:

    if (query.action === "MONITORON")
    		{
    			exec("tvservice --preferred && sudo chvt 6 && sudo chvt 7", opts, function(error, stdout, stderr){ self.checkForExecError(error, stdout, stderr, res); });
    			return true;
    }
    

    Notes:

    • query.action defines a trigger word for the MMM-RemoteControl to listen for.
    • exec() - executes a command on the OS
    • The rest is for error checking that the external command executed.

    In your case, we could define the following:

    if (query.action === "MOTIONON")
    		{
    			exec("echo "motion_enable on" > ~/pikrellcam/www/FIFO", opts, function(error, stdout, stderr){ self.checkForExecError(error, stdout, stderr, res); });
    			return true;
    }
    
    if (query.action === "MOTIONOFF")
    		{
    			exec("echo "motion_enable off" > ~/pikrellcam/www/FIFO", opts, function(error, stdout, stderr){ self.checkForExecError(error, stdout, stderr, res); });
    			return true;
    }
    

Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.