This is a module for MagicMirror² to send events to a Pimatic installation.
To install the module, just clone this repository in your modules folder:
git clone https://github.com/qistoph/MMM-pimatic.git pimatic
The run cd pimatic
and npm install
to install the dependencies.
Pull the git updates: git pull
.
The update dependencies in the module folder: cd pimatic
followed by npm install
.
To use this module, add it to the modules array in the config/config.js
file:
modules: [
{
module: 'pimatic',
config: {
url: 'https://host.com:8080/api/',
username: 'magicmirror',
password: 'PASSWORD'
}
}
]
The following properties can be configured:
Option | Description |
---|---|
url |
The URL to your pimatic API. Should include the port and the /api/ suffix.Example: https://your.host:8443/api/ Required |
username |
The username to use for API calls. Required |
password |
The password to use for API calls. Required |
mappings |
An array of mappings used to convert notifications to Pimatic calls. See Mappings for details. Required |
Simple functions are used to convert notifications to Pimatic calls. mappings
must contain an array of functions with the signature
function(notification, payload, sender)
and must return undefined
or a named
array with the following parameters:
Key | Value |
---|---|
uri |
The API uri to call, e.g. device/DEVICE_NAME/ACTION |
params |
A named array with parameters to send as query string in the GET request |
If your pimatic installation has a DummuPresenceSensor
with the id
magicmirror-presence
you could use the following samples to change its
presence when USER_PRESENCE
notifactions are received.
mappings: [
function(notification, payload, sender) {
if (notification == "USER_PRESENCE" && payload == true) {
return {"uri": "device/magicmirror-presence/changePresenceTo", "params": {"presence": "true"}};
}
}
]
mappings: [
function(notification, payload, sender) {
if (notification == "USER_PRESENCE") {
return {"uri": "device/magicmirror-presence/changePresenceTo", "params": {"presence": (payload === true) }};
}
}
]