Coder Social home page Coder Social logo

mmm-mqtt's Introduction

MQTT

NB! New config!

In order to support multiple instances and multiple servers, the configuration is totally changed! Sorry to not be backwards compatible, but I hope this solves some of the issues I have received.

Please report issues. his is not tested very much.

Screenshot

Screenshot

Module for MagicMirror showing the payload of a message from MQTT.

Installasjon

Go to MagicMirror/modules and write

git clone https://github.com/ottopaulsen/MMM-MQTT
cd MMM-MQTT
npm install

Configuration

Here is an example configuration with description. Put it in the MagicMirror/config/config.js file:

{
    module: 'MMM-MQTT',
    position: 'bottom_left',
    header: 'MQTT',
    config: {
        mqttServers: [
            {
                address: 'localhost',  // Server address or IP address
                port: '1883',          // Port number if other than default
                user: 'user',          // Leave out for no user
                password: 'password',  // Leave out for no password
                subscriptions: [
                    {
                        topic: 'smoky/1/inside/temperature', // Topic to look for
                        label: 'Temperatur', // Displayed in front of value
                        suffix: '°C',        // Displayed after the value
                        decimals: 1,         // Round numbers to this number of decimals
                        sortOrder: 10,       // Can be used to sort entries in the same table
                        maxAgeSeconds: 60    // Reduce intensity if value is older
                    },
                    {
                        topic: 'smoky/1/inside/humidity',
                        label: 'Luftfuktighet',
                        suffix: '%',
                        decimals: 0,
                        sortOrder: 20,
                        maxAgeSeconds: 60
                    },
                    {
                        topic: 'smoky/1/inside/smoke',
                        label: 'Røyk',
                        sortOrder: 30,
                        maxAgeSeconds: 60
                    },
                    {
                        topic: 'guests',
                        label: 'First guest',
                        jsonpointer: '/people/0/name'
                    }
                ]
            }
        ],
    }
}

mqttServers is an array, so you can add multiple servers to the same config. You can also use the module multiple places on the mirror/screen.

JSON Data

If the payload contains JSON data, use the jsonpointer configuration to get the value. See JSON Ponter specification or google an easier description.

Styling

Styling can be done in the MQTT.css file. The table header can be styled using locator #module_3_MMM-MQTT > header. The column text can be styled using the following classes:

.mqtt-label {}
.mqtt-value {}
.mqtt-suffix {}

Collaborate

Pull requests are welcome.

TO DO

Create a timeout, so values are deleted if they are not refreshed. May be faded out...

Create a treshold so a value is flashing if outside treshold.

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.