eouia / MMM-Whereis

MagicMirror module to display where someone is (with IFTTT)
MIT License
5 stars 1 forks source link

MMM-Whereis

MagicMirror module to display where someone is (with IFTTT)

Screenshot

screenshot

Installation

cd ~/MagicMirror/modules
git clone https://github.com/eouia/MMM-Whereis

Configuration

{
  module: "MMM-Whereis",
  position: "top_left",
  config: {
    refreshInterval: 1000 * 30,
    timeFormat: "relative", // or "YYYY-MM-DD HH:mm:ss" format
    iconify: "https://code.iconify.design/1/1.0.2/iconify.min.js",
      //iconify: null,
      //When you use this module with `MMM-CalendarExt2`, `MMM-Spotify` or any other `iconify` used modules together, Set this to null.
    enterIcon: "icomoon-free:enter",
    exitIcon: "icomoon-free:exit",
    member: {
      "dad": {
        title: "Daddy",
        icon: "emojione-old-man",
      },
      "mom": {
        title: "Mommy",
        icon: "emojione-woman-dancing",
      },
      "son": {
        title: "Tommy",
        icon: "uil-kid"
      }
    },
    commands: {
      "dad-exited-Office": {
        notificationExec: {
          notification: "SHOW_ALERT",
          payload: { message: "Dad is coming home!", timer: 5000 }
        }
      }
    }
  }
}

IFTTT setup

step 1.

Go to IFTTT (https://ifttt.com) and sign in. Then create new app. screenshot

step 2.

Search location and set it as THIS of IFTTT

  1. screenshot

  2. screenshot

  3. screenshot

step 3.

Now, THAT part screenshot

  1. Select Webhooks screenshot

  2. screenshot

  3. screenshot

    • URL: Your MagicMirror domain:port + /whereis (e.g: mymirror.com:8080/whereis)
    • Method: POST
    • Content Type: application/json
    • Body :
      {
      "who": "dad",
      "location": "Office",
      "EnteredOrExited": {{EnteredOrExited}}
      }

step 4.

After creation, You should allow your IFTTT app of your smartphone could use your location information always.

Commands.

You can make a custom command with who-entered/exited-location pattern. (e.g: dad-entered-home)

0. Common

You can define your custom commands like this;

commands: {
  "who-entered-location": {
    notificationExec: { ... },
    // And/Or
    shellExec: { ... },
    // And/Or
    moduleExec: { ... },
  },
  ...
}

1. notificationExec

Command can emit notification of MagicMirror. When you need to activate other module with notification, this could.

commands: {
  "dad-entered-home": {
    notificationExec: {
      notification: "SHOW_ALERT",
      payload: {message:"Okaeri, Papa!", timer:2000}
    }
  }
}

2. shellExec

Command can execute some simple shell script (e.g: python or bash script). But it just executes the shell command. Process executed by this is not controllable or manageable. If you need more, make your own module for it.

commands: {
  "dad-exited-home": {
    shellExec: {
      exec: "sudo shutdown now"
    }
  }
}

3. moduleExec

Command can also handle module(s) itself.

commands: {
  "mom-exited-home": {
    moduleExec: {
      module: ["clock"],
      exec: (module, time) => {
        module.hide()
      }
    }
  }
}

Note.