jopyth / mmm-buttons Goto Github PK
View Code? Open in Web Editor NEWThis module can be used to to connect buttons to your Magic Mirror²
This module can be used to to connect buttons to your Magic Mirror²
The plugin works fine for what I'm doing but in order for it to work I have to run a python based test program I have for testing the buttons. Once I do that it all works great. I have to do this every time the pi is rebooted. Any ideas?
I am running magic mirror in a docker container however, after fixing an error with electron by installing electron by hand and editing the path in the package.json see issue: #7
Now magic mirror can't start and i get the following docker logs:
[2020-12-16 18:34:53.575] [ERROR] Error: The module '/opt/magic_mirror/modules/MMM-Buttons/node_modules/epoll/build/Release/epoll.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 85. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1208:18)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at bindings (/opt/magic_mirror/modules/MMM-Buttons/node_modules/bindings/bindings.js:112:48)
at /opt/magic_mirror/modules/MMM-Buttons/node_modules/epoll/epoll.js:7:31
at Object.<anonymous> (/opt/magic_mirror/modules/MMM-Buttons/node_modules/epoll/epoll.js:15:3)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
i have already tried npm rebuild
and ./node_modules/.bin/electron-rebuild
Does this has to do with the electron version? What can i possibly do to fix the issue?
Thank you for your support :)
excuse me, @Jopyth what electron version are you using? (It isn't specified in the package.json file)
Config:
MM 2.4.1
Raspie 3b+
installed modules
MMM-RemoteControl
MMM-howord
MMM-Assistantmk2
MMM-Notificationtrigger
workin in SERVERONLY mode
after installing screen goes black
Message in the console module compiled for a different NODE version
I rebuilt Buttons (npm rebuild in the directory)
still black screen but no error anymore
after removing all references to buttons screen comes back but assistant just answers first question then bails out with error
I'm receiving the following error when trying to install MMM-Buttons:
pi@MagicMirror:~/MagicMirror/modules/MMM-Buttons $ npm install
> [email protected] postinstall
> node_modules/.bin/electron-rebuild -e node_modules/electron
⠋ Searching dependency tree
An unhandled error occurred inside electron-rebuild
Could not detect abi for version 17.0.1 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron
Error: Could not detect abi for version 17.0.1 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron
at Object.getAbi (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/node-abi/index.js:36:9)
at new Rebuilder (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/rebuild.js:126:48)
at rebuildWithOptions (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/rebuild.js:404:23)
at Object.doRebuild [as rebuild] (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/rebuild.js:427:16)
at /home/pi/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/cli.js:124:33
at Generator.next (<anonymous>)
at fulfilled (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/cli.js:6:58)
npm ERR! code 255
npm ERR! path /home/pi/MagicMirror/modules/MMM-Buttons
npm ERR! command failed
npm ERR! command sh -c node_modules/.bin/electron-rebuild -e node_modules/electron
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2022-02-18T11_12_17_532Z-debug-0.log
It seems that the sh -c node_modules/.bin/electron-rebuild -e node_modules/electron
command causes problems.
Any solution to this?
fails with following output:
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/home/pi/MagicMirror/modules/MMM-Button/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (node:events:390:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Linux 5.10.17-v7+
gyp ERR! command "/usr/bin/node" "/home/pi/MagicMirror/modules/MMM-Button/node_modules/.bin/node-gyp" "rebuild" "--target=15.3.0" "--arch=arm" "--dist-url=https://www.electronjs.org/headers" "--build-from-source"
gyp ERR! cwd /home/pi/MagicMirror/modules/MMM-Button/node_modules/epoll
gyp ERR! node -v v17.0.1
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok
Failed with exit code: 1
at SafeSubscriber._error (/home/pi/MagicMirror/modules/MMM-Button/node_modules/spawn-rx/lib/src/index.js:267:84)
at SafeSubscriber.__tryOrUnsub (/home/pi/MagicMirror/modules/MMM-Button/node_modules/rxjs/internal/Subscriber.js:205:16)
at SafeSubscriber.error (/home/pi/MagicMirror/modules/MMM-Button/node_modules/rxjs/internal/Subscriber.js:156:26)
at Subscriber._error (/home/pi/MagicMirror/modules/MMM-Button/node_modules/rxjs/internal/Subscriber.js:92:26)
at Subscriber.error (/home/pi/MagicMirror/modules/MMM-Button/node_modules/rxjs/internal/Subscriber.js:72:18)
at MapSubscriber.Subscriber._error (/home/pi/MagicMirror/modules/MMM-Button/node_modules/rxjs/internal/Subscriber.js:92:26)
at MapSubscriber.Subscriber.error (/home/pi/MagicMirror/modules/MMM-Button/node_modules/rxjs/internal/Subscriber.js:72:18)
at SafeSubscriber._next (/home/pi/MagicMirror/modules/MMM-Button/node_modules/spawn-rx/lib/src/index.js:242:65)
at SafeSubscriber.__tryOrUnsub (/home/pi/MagicMirror/modules/MMM-Button/node_modules/rxjs/internal/Subscriber.js:205:16)
at SafeSubscriber.next (/home/pi/MagicMirror/modules/MMM-Button/node_modules/rxjs/internal/Subscriber.js:143:22)
any ideas?
Hello
I cannot get short presses intercepted
I am 100% sure the buttons work
I checked both outside of magicmirror and inside )added a couple of console.log to the module)
Button down is intercepted button up too ,
Long press is ok
just no short press.
tried modifying the default values
but no luck
I have a strange issue with button press. I have to press it twice quickly to trigger action. Pressing it just once or holding it down does not work.
Anyone have the same strange issue I have?
The notification pup-up and do not disappear. I want to set time the notification appear and disappear. I try to set timer: "10000" to visible notification in 10s. But the config.js file was not has affected.
Here the code:
longPress: {
title: "Power off",
message: "Keep pressed for 3 seconds to shut down",
imageFA: "power-off",
notification: "REMOTE_ACTION",
payload: {action: "REBOOT"},
timer: "10000",
},
PLease tell me how to set that time.
Hello the project is very nice.
I want to send notification play when I press the button and when I'm going to release the button to send notification pause.
Where I have to write this.
I was wondering if you know how to get a physical button to work with MMM-carousel. I have been struggling to get the button to move the slides. Its been a while and i lost progress i had. tried this just to get one slide button working to no avail.
` {
module: 'MMM-Buttons',
config: {
buttons: [
{
pin: 25,
name: "monitor_control",
longPress: {
notification: "REMOTE_ACTION",
payload: {action: "MONITOROFF"}
},
shortPress: {
notification: "REMOTE_ACTION",
payload: {action: "MONITORON"}
}
},
{
pin: 18,
name: "ArrowRight",
shortPress: {
notification: "CAROUSEL_NEXT",
payload: {action: "CAROUSEL_NEXT"}
},
longPress: undefined
}
]
}
},
`
I got an error after installing the module.
Whoops! There was an uncaught exception...
Error: Module version mismatch. Expected 48, got 53.
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at bindings (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/epoll/epoll.js:1:99)
at Module._compile (module.js:570:32)
So I googled a bit and found a solution:
npm rebuild
After I ran this in the MMM-Buttons-folder it works. I don't know exactly what it did, but I want to inform the contributors or other folks who want to install this.
I've been playing with the code and like another issue I can't get shortpresses ever.
only long presses and the timer seems to control all buttons, not just the one that was pressed.
Hi!
I have problem… When I connect the two pins (pin 9 and pin 11 / Ground & GPIO 17) it doesn’t change the profile…
Can you help out here? That would be great!
This is my config:
var config = {
address: "localhost", // Address to listen on, can be:
// - "localhost", "127.0.0.1", "::1" to listen on loopback interface
// - another specific IPv4/6 to listen on a specific interface
// - "", "0.0.0.0", "::" to listen on any interface
// Default, when address config is left out, is "localhost"
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses
// or add a specific IPv4 of 192.168.1.5 :
// ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
// or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
// ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
language: "de",
timeFormat: 24,
units: "metric",
modules: [
{
module: "alert",
classes: "default everyone"
},
{
module: "updatenotification",
position: "top_bar",
classes: "default everyone"
},
{
module: "clock",
position: "top_left",
classes: "default everyone"
},
{
module: "newsfeed",
position: "bottom_bar",
classes: "default",
config: {
feeds: [
{
title: "Neue Zürcher Zeitung",
url: "https://www.nzz.ch/recent.rss"
},
],
showSourceTitle: true,
showPublishDate: true,
broadcastNewsFeeds: true,
broadcastNewsUpdates: true
}
},
{
module: "MMM-CalendarExt",
position: "top_left",
classes: "default everyone",
config: {
system: {
show: ["daily"],
locale: 'de',
redrawInterval:60000,
},
views: {
daily: {
position:'lower_third',
counts:7,
},
},
defaultCalendar: {
maxEntries:50,
maxDays:180,
interval: 1000*60*5,
},
calendars :[
{
name: "Tommaso",
url: "https://calendar.google.com/calendar/ical/tommaso.peduzzi%40gmx.ch/private-088063fff967db8474e57b3a7cdf176a/basic.ics",
profiles: ['Tom'],
},
{
name: "Ferien",
url: "https://www.ferienwiki.ch/exports/ferien/2019/ch/basel-stadt",
profiles: ['default'],
},
],
},
},
{
module: 'MMM-ProfileSwitcher',
classes: "default everyone",
config: {
// See 'Configuration options' for more information.
}
},
{
module: "currentweather",
classes: "default",
position: "top_right",
config: {
location: "Basel",
locationID: "6458763", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
appid: "4a58442ce61f6ae3de20fcfdecdb0327"
}
},
{
module: "weatherforecast",
classes: "default everyone",
position: "top_right",
header: "Weather Forecast",
config: {
location: "Basel",
locationID: "6458763", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
appid: "4a58442ce61f6ae3de20fcfdecdb0327"
}
},
/*{
module: 'MMM-GPIO-Notifications',
classes: "default everyone",
config: {
'17': {
gpio_state: 1,
gpio_debounce: 10,
notifications: [
{
// see https://github.com/tosti007/MMM-ProfileSwitcher
// Switching Profiles
// this.sendNotification('CURRENT_PROFILE', 'DESIRED_PROFILE_NAME_HERE');
notification: 'CURRENT_PROFILE',
payload: 'Tom'
},
]
}
}
},*/
{
module: 'MMM-Buttons',
config: {
buttons: [
{
pin: 17,
name: "monitor_control",
shortPress: {
notification: "CURRENT_PROFILE",
payload: "Tom"
},
},
]
}
},
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {module.exports = config;}
Thanks alot,
Tom
can somebody help me to make it work with page-selector... what is the changes I have to make in witch file ? I want to use 2 buttons , 1 to increment page and the other to decrement (I've just begin learn javascript :-( )
hi ,
i have node 11 and when i install with this command : sudo npm install
npm WARN lifecycle [email protected]~postinstall: cannot run in wd [email protected] electron-rebuild -e ../../node_modules/electron (wd=/home/yuval/Docker/MagicMirror/modules/MMM-Buttons)
audited 301 packages in 1.253s
found 0 vulnerabilities
and with this command : sudo npm -g install
> [email protected] postinstall /home/yuval/Docker/MagicMirror/modules/MMM-Buttons
> electron-rebuild
An unhandled error occurred inside electron-rebuild
Unable to find electron-prebuilt's version number, either install it or specify an explicit version
Error: Unable to find electron-prebuilt's version number, either install it or specify an explicit version
at Object.<anonymous> (/home/yuval/Docker/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/cli.js:81:19)
at Generator.next (<anonymous>)
at /home/yuval/Docker/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/cli.js:8:71
at new Promise (<anonymous>)
at __awaiter (/home/yuval/Docker/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/cli.js:4:12)
at /home/yuval/Docker/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/cli.js:70:8
at Object.<anonymous> (/home/yuval/Docker/MagicMirror/modules/MMM-Buttons/node_modules/electron-rebuild/lib/src/cli.js:146:4)
at Module._compile (internal/modules/cjs/loader.js:805:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)
at Module.load (internal/modules/cjs/loader.js:672:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 255
npm ERR! [email protected] postinstall: `electron-rebuild`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/yuval/.npm/_logs/2019-04-03T11_35_21_386Z-debug.log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.