MagicMirror module to display where someone is (with IFTTT)
cd ~/MagicMirror/modules
git clone https://github.com/eouia/MMM-Whereis
{
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 }
}
}
}
}
}
Go to IFTTT (https://ifttt.com) and sign in. Then create new app.
Search location
and set it as THIS
of IFTTT
Now, THAT
part
Select Webhooks
Your MagicMirror domain:port
+ /whereis
(e.g: mymirror.com:8080/whereis
) POST
application/json
{
"who": "dad",
"location": "Office",
"EnteredOrExited": {{EnteredOrExited}}
}
After creation, You should allow your IFTTT app of your smartphone could use your location information always.
You can make a custom command with who-entered/exited-location
pattern. (e.g: dad-entered-home
)
You can define your custom commands like this;
commands: {
"who-entered-location": {
notificationExec: { ... },
// And/Or
shellExec: { ... },
// And/Or
moduleExec: { ... },
},
...
}
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}
}
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.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)