@flipfloplife you could still be in text mode (console mode) vs the graphical desktop…
xwindows is display:0, so you shouldn’t have to change anything…
@flipfloplife you could still be in text mode (console mode) vs the graphical desktop…
xwindows is display:0, so you shouldn’t have to change anything…
@AxLed said in [MMM-Remote-Control] Cannot GET /api:
api/module/alert/showalert?message=Hello&timer=2000
it looks like the api was changed, but not documented…
looking thru node_helper.js you can see all the commands
ip:port/remote?action=xxxxx&parms=???&parms2=???
the code lists these actions
if (query.action === "SHUTDOWN") {
if (query.action === "REBOOT") {
if (query.action === "RESTART" || query.action === "STOP") {
if (query.action === "USER_PRESENCE") {
if (["MONITORON", "MONITOROFF", "MONITORTOGGLE", "MONITORSTATUS"].indexOf(query.action) !== -1) {
this.monitorControl(query.action, opts, res);
if (query.action === "HIDE" || query.action === "SHOW" || query.action === "TOGGLE") {
self.sendSocketNotification(query.action, query);
if (query.action === "BRIGHTNESS") {
self.sendSocketNotification(query.action, query.value);
if (query.action === "SAVE") {
if (query.action === "MODULE_DATA") {
if (query.action === "INSTALL") {
if (query.action === "REFRESH") {
self.sendSocketNotification(query.action);
if (query.action === "HIDE_ALERT") {
self.sendSocketNotification(query.action);
if (query.action === "SHOW_ALERT") {
self.sendSocketNotification(query.action, {
if (query.action === "UPDATE") {
if (query.action === 'NOTIFICATION') {
this.sendSocketNotification(query.action, { 'notification': query.notification, 'payload': payload });
if (["MINIMIZE", "TOGGLEFULLSCREEN", "DEVTOOLS"].indexOf(query.action) !== -1) {
switch (query.action) {
if (query.action === "DELAYED") {
to send an alert thru the api
http://mirror_ip:mirror_port/remote?action=SHOW_ALERT&message=foo&title=help&timer=10&type=alert
the remote.html does NOT use the api, but uses the socketNotifications pipe under the covers.
which is why it works, but the older /api/modulename… approach doesn’t
@buzzkc so, with promises, you have a ‘then’, with a ‘resolve’ and an ‘error’ callback, and the resolve and reject methods of the promise can provide data to the resolve and error routines…
just a reminder, the return new Promise() returns IMMEDIATELY… the function inside the promise is called async sometime (milliseconds) later
function_name: function(parm1_in, parm2_in) {
return new Promise( function (resolve,reject){
if( all_good) {
resolve(data_item)
}
else {
reject(error_data)
}
}
)
then the method CALLING this function
function_name(parm1, parm2).then(
resolve_func(data_item){ },
error_func(error_data){}
)
a working example , using the arrow function (parm) => {
the arrow function insures that the data context of the outside caller is maintained,
where as function(parm) { does not (u had to use the ‘self =this’ thing
let promise = new Promise(function(resolve, reject) {
if(!setTimeout(() => resolve("done!"), 1000)){
reject("settimeout_failed")
}
});
// resolve runs the first function in .then, reject runs the second function
promise.then( // this will block until the function inside the promise call resolve or reject
result => alert(result), // shows "done!" after 1 second
error => alert(error) // doesn't run .. this will never occurr as settimeout never fails.
);
and my MMM-SleepWake works with webcam for motion detection and Lucy for remembering which modules are hidden when waking by voice or movement
and supports three different screen off approaches, tvservice (pi only) dpms (some monitors) and screen blanking(for auto power off devices, like TVs, EnergyStar)
@Stoffbeuteluwe this is due to a new restriction on the browser
do this
edit MagicMirror/js/electron.js
and add the line shown below
let mainWindow;
function createWindow() {
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required'); //< -------- added
save and restart MagicMirror
@bhepler i added handling for the git lock file…
if git is NOT running, I erase the dangling lock file
if git IS running, and this is an APPLY run, i change the run back to test mode, and advise to correct the problem
@mdhenriksen said in Can't install / Error with NPM / Electron not found:
libgconf-2.so.4
a google search for ‘error while loading shared libraries: libgconf-2.so.4’
see https://github.com/electron/electron/issues/1518
@castletonroad I’m not sure this will help, but the local mirror web server is not on port 80, but typically on 8080 (port setting in config.js)
so, your url should be
url: "http://127.0.0.1:8080/modules/calendars/basic.ics"
and the mirror web server base directory is the modules folder… so your file would need to be located in that directory tree somewhere
I downloaded my calendar, and it works fine locally
url: "http://localhost:8086/modules/cals/basic.ics"
my mirror is running on port 8086.
some users are using older PI hardware, based on the armv6 chipset. Unfortunately the electron browser is no longer built for that chipset, and forcing armv7 no longer works.
so I propose an update to the run-start.sh script which will detect this and use the chromium browser instead. this helps because the impacted users don’t have to learn to modify the run-start file or the why
its slower to start up, but just as functional
(we also need to make the electron dependency optional, so the install will complete)
also, in some cases our users would like to run serverOnly mode, so I think we could add a config.js option to enable that, and use the same update to run-start to just NOT start a browser…
serverOnly: "local" or true or false (default)
true means runserveronly, but no UI ON the local system
"local" means runserveronly, also run UI ON the local system, default for armv6
false (default), means do not run serveronly default for NOT armv6
here is my proposed change to run-start.sh (extra spaces to handle the forum chopping off stuff after < )
#!/bin/bash
# use bash instead of sh
./untrack-css.sh
if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
export DISPLAY=:0 # Set by default display
fi
# get the processor architecture
arch=$(uname -m)
# got the config option, if any
serveronly=$(grep -i serveronly: config/config.js | awk '{print tolower($2)}' | tr -d ,\"\')
# set default if not defined in config
serveronly="${serveronly:=false}"
# check for xwindows running
xorg=$(pgrep Xorg)
#
# if the user requested serveronly OR
# electron support for armv6l has been dropped OR
# system is in text mode
#
if [ "$serveronly." != "false." -o "$arch" == "armv6l" -o "$xorg." == "." ]; then
# if user explicitly configured to run server only (no ui local)
# OR there is no xwindows running, so no support for browser graphics
if [ "$serveronly." == "true." -o "$xorg." == "." ]; then
# start server mode,
node serveronly
else
# start the server in the background
# wait for server to be ready
# need bash for this
exec 3< < (node serveronly)
# Read the output of server line by line until one line 'point your browser'
while read line; do
case "$line" in
*point\ your\ browser*)
echo $line
break
;;
*)
echo $line
#sleep .25
;;
esac
done < &3
# Close the file descriptor
exec 3< &-
# lets use chrome to display here now
# get the server port address from the ready message
port=$(echo $line | awk -F\: '{print $4}')
# start chromium
echo "Starting chromium browser now, have patience, it takes a minute"
chromium-browser -noerrdialogs -kiosk -start_maximized --disable-infobars --app=http://localhost:$port --ignore-certificate-errors-spki-list --ignore-ssl-errors --ignore-certificate-errors 2>/dev/null
exit
fi
else
# we can use electron directly
`electron js/electron.js $1`;
fi