A MagicMirror module to send notifications to other modules using flic buttons (see MagicMirror Module documentation for information about notifications). This module uses fliclib-linux-hci and therfore only works on Linux on the following architectures: armv6l, i386 and x86_64
Navigate to the modules
folder and clone the repository with all submodules:
git clone --recurse-submodules https://www.github.com/nomis6432/MMM-flicio
Navigate to the config/config.js
file and add a new entry in modules
(see MagicMirror Module Configuration documentation).
Before adding the config
parameter you should first register your buttons. This module uses fliclib-linux-hci and will spawn the flicd deamon when MagicMirror launches. In order to register the buttons you should first launch MagicMirror (or launch flicd manually with the flic.sqlite3
file located in the root folder of this module). Once this is done run npm run register
from within the root folder of this module. Follow the instructions to register the button. You'll need the MAC address that appears to configure your button. You can run npm test
to test your buttons.
The config
attribute has 3 parameters:
allowQueued
: can betrue
orfalse
. Whenfalse
all button inputs that couldn't be delivered withinqueueTimeout
seconds will be discarded.true
by default.queueTimeout
: number of seconds to wait whenallowQueued
isfalse
. Is ignored whenallowQueued
istrue
.5
by default.buttons
: an Object with as key the MAC addresses of the buttons and as value another Object. This Object has as key as String describing the button action, either'ButtonSingleClick'
,'ButtonDoubleClick'
, or'ButtonHold'
. The value of this Object is a list of Objects containingnotification
(a String) with the notification andpayload
(Any Type, optionally) the payload that should be sent together with that notification.
An example of a module entry:
{
module: "MMM-flicio",
config: {
allowQueued: false,
buttons: {
"AA:BB:CC:DD:EE:FF": {
ButtonSingleClick: [
{
notification: "DO-SOMETHING",
payload: {
foo: "bar",
foofoo: "barbar"
}
},
{
notification: "ALSO-DO",
}
]
},
"11:22:33:44:55:66": {
ButtonSingleClick: [
{
notification: "DO-SOMETHING-COOL",
payload: "foo"
}
],
ButtonDoubleClick: [
{
notification: "DO-SOMETHING-ELSE-COOL",
payload: {
foo: "bar"
}
}
],
ButtonHold: [
{
notification: "DO-SOMETHING-EXTRA-COOL"
}
]
}
}
},
}
This module will also send a notification 'FLICIO-connectionStatusChanged'
whenever the connection status of a button changes. The payload of this notification is an Object with as attributes:
bdAddr
: the MAC address of the button of which the connection changed.connectionStatus
: the current connection status:"Disconnected"
or"Connected"
.disconnectReason
: the reason for the disconnect.