GithubHelp home page GithubHelp logo

mmm-whereis's Introduction

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}
    }
  }
}
  • notification : String or callback function(time) which will return String By example; This could emit conditional notification
notification: (time) => {
  if (SOME CONDITION) {
    return "SOME_NOTIFICATION"
  } else {
    return "OTHER_NOTIFICATION"
  }
}
  • time is Unix Epoch time (by Date.now())
  • payload : Any Variables(include Object) could be. Or callback function(time) which will return payload could be.
payload: (time) => {
  return {"eventTime": time}
}

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"
    }
  }
}
  • exec: String or callback function also.

3. moduleExec

Command can also handle module(s) itself.

commands: {
  "mom-exited-home": {
    moduleExec: {
      module: ["clock"],
      exec: (module, time) => {
        module.hide()
      }
    }
  }
}
  • module : String of target module name or Array of names of target modules or just [](for all modules). And also could be callback function which will return string or array.
module: "clock", // This means `clock` module
module: ["clock"], // same with above.
module: ["clock", "calendar"] // This means `clock` module and `calendar` module
module: [], // This means targeting all modules
module: (time) => { return "clock" },
module: (time) => { return ["clock", "calendar"]}
module: (time) => { return [] }
  • exec : callback function to do its job. Arguments are slightly different with other callbacks.
exec: (module, time) => {
  module.hide()
}
  • module: would be targeted module(s)

Note.

  • This module cannot detect "WHERE (S)HE IS NOW" (differnt with module name. :D). It detect "Entry or Exit of People on Specific Location".
  • "unknown" will be displayed until new IFTTT event be received.
  • You should have Static IP/Domain or at least DDNS.

mmm-whereis's People

Contributors

eouia avatar

Stargazers

 avatar  avatar  avatar Cederic Privat avatar Solomon avatar

Watchers

James Cloos avatar

Forkers

rubenix

mmm-whereis's Issues

IFTTT Configuration

Hello,

I install this module but it doesn't work.
Maybe I did wrong configuration on IFTTT.

At the step 2, URL, can I made my own raspberry pi IP ? (It's a static IP)
For example : 192.168.1.3/whereis

Also, another thing, can I made two IFTTT location for one user ?
For example :
{
"who": "dad",
"location": "Office",
"EnteredOrExited": {{EnteredOrExited}}
}
and :
{
"who": "dad",
"location": "Home",
"EnteredOrExited": {{EnteredOrExited}}
}

And, last thing, I don't understand why the size of the font is big on my mirror.
How can I reduce them ? I try to modify some stuffs on the css file but none work.

Thanks for your answers ! :)

location not changing.

Hi, im cant get this module to work.
config for module is
{
module: "MMM-Whereis",
position: "bottom_left",
config: {
refreshInterval: 1000 * 30,
timeFormat: "relative",
iconify: "https://code.iconify.design/1/1.0.2/iconify.min.js",
enterIcon: "icomoon-free:enter",
exitIcon: "icomoon-free:exit",
member: {
"dad": {
title: "Daddy",
icon: "emojione-man",
},
"son": {
title: "Luca",
icon: "uil-kid"
}
},
}
},

im sending
curl -d '{"who":"dad", "location":"work", "enteredorexit":"entered"}' -H "Content-Type: application/json" -X POST "http://192.168.1.157:6523/Whereis"

this is sent from pi mirror is running from, if i try sending from remote i can token error.

in console i get response >see output.txt
text refreshes, but location still says unknown.
output.txt

thanks

john

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.