Code Monkey home page Code Monkey logo

mmm-pimatic's Introduction

Pimatic - MagicMirror² module

Build Status

This is a module for MagicMirror² to send events to a Pimatic installation.

Installing the module

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.

Updating the module

Pull the git updates: git pull. The update dependencies in the module folder: cd pimatic followed by npm install.

Using the module

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'
    }
  }
]

Configuration options

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

Mappings

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.

Send present only

mappings: [
  function(notification, payload, sender) {
    if (notification == "USER_PRESENCE" && payload == true) {
      return {"uri": "device/magicmirror-presence/changePresenceTo", "params": {"presence": "true"}};
    }
  }
]

Send present and absent events

mappings: [
  function(notification, payload, sender) {
    if (notification == "USER_PRESENCE") {
      return {"uri": "device/magicmirror-presence/changePresenceTo", "params": {"presence": (payload === true) }};
    }
  }
]

mmm-pimatic's People

Contributors

qistoph avatar

Watchers

 avatar

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.