Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring up to v 31 #950

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ app/css/local.css
.gitignore
.prettierrc
.editorconfig
plugins/
!.gitkeep
32 changes: 32 additions & 0 deletions .gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins/autosleep
plugins/calendar
plugins/commands
plugins/commitstrip
plugins/datetime
plugins/dilbert
plugins/fitbit
plugins/_general
plugins/geolocation
plugins/giphy
plugins/greeting
plugins/ha-display
plugins/light
plugins/maker
plugins/map
plugins/pluginconfig
plugins/reminder
plugins/remote
plugins/rss
plugins/scrobbler
plugins/search
plugins/soundcloud
plugins/speech
plugins/spotify
plugins/stock
plugins/timebox
plugins/timer
plugins/todoist
plugins/traffic
plugins/tvshows
plugins/weather
plugins/xkcd
19 changes: 13 additions & 6 deletions app/css/newfile.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
:root{
--scale-factor: 1; /* set default scaling in case we have partial window, debug or in vm terminal window */
--design-width: 1920px;
--design-height: 1080px;
}

@media screen and (width:1920px) and (orientation: landscape) {
@media screen and (orientation: landscape) {
:root{
--scale-factor: 1920/1920;
--scale-factor: var(width) / var(--design-width);
};
}
@media screen and (orientation: portrait) {
:root{
--scale-factor: var(width) / var(--design-height);
};
}

@media screen and (width:3840px) and (orientation: landscape) {
/*@media screen and (width:3840px) and (orientation: landscape) {
:root{
--scale-factor: 3840/1920;
--scale-factor: width/var(--design-width);

};
}
@media screen and (width:1080px) {
:root{
--scale-factor: 1920/1920;
--scale-factor: width/var(--design-width);
};
}
}*/



Expand Down
2 changes: 1 addition & 1 deletion app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
.config(function (tmhDynamicLocaleProvider) {
console.log(config);
tmhDynamicLocaleProvider.localeLocationPattern(
"bower_components/angular-i18n/angular-locale_" +
"node_modules/angular-i18n/angular-locale_" +
language +
".js"
);
Expand Down
10 changes: 1 addition & 9 deletions app/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Focus,
SpeechService,
AutoSleepService,
// LightService,
$rootScope,
$scope,
$timeout,
Expand Down Expand Up @@ -93,6 +92,7 @@
$scope.focus = AutoSleepService.scope;
AutoSleepService.startAutoSleepTimer();
}
$rootScope.$broadcast("clock-tick",$scope.date)
}
var clearListening = function(){
$scope.listening = false;
Expand Down Expand Up @@ -183,14 +183,6 @@
console.debug("It is", moment().format("h:mm:ss a"));
});

// Control light
/* SpeechService.addCommand("light_action", function (
state,
target,
action
) {
LightService.performUpdate([state, target, action].join(" "));
}); */
};

_this.init();
Expand Down
57 changes: 49 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ const remote = require("./remote.js");
const app = electron.app;
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow;
// Replace with:
const debug =false;
//const { BrowserWindow } = require('@electron/remote/main')

// In the main process:
require('@electron/remote/main').initialize()
// Prevent the monitor from going to sleep.
const powerSaveBlocker = electron.powerSaveBlocker;
powerSaveBlocker.start("prevent-display-sleep");
Expand All @@ -17,7 +23,31 @@ const getPort = require("get-port");

// Launching the mirror in dev mode
const DevelopmentMode = process.argv.includes("dev");
const usepm2 = process.argv.includes("usepm2");
let usepm2 = false;

//if (debug) console.log("getting pm2 process list");
exec("pm2 jlist", (error, stdout) => {
if (!error) {
let output = JSON.parse(stdout);
if (debug)
console.log(
"processing pm2 jlist output, " + output.length + " entries"
);
output.forEach((managed_process) => {
if(debug)
console.log("comparing "+__dirname +" with "+ managed_process.pm2_env.pm_cwd )
// if we find a pm2 process matching our location
// and that process is online, then it is us
if (managed_process.pm2_env.pm_cwd.startsWith(__dirname) && managed_process.pm2_env.status ==="online") {
if (debug)
console.log(
"found our pm2 entry, id=" + managed_process.pm_id
);
usepm2 = true;
}
});
}
});
//var atomScreen = null;
// Load the smart mirror config
let config;
Expand Down Expand Up @@ -67,6 +97,7 @@ function createWindow() {
break;
}
}

const { width, height } = atomScreen.getPrimaryDisplay().workAreaSize;
var browserWindowOptions = {
width: width,
Expand All @@ -80,14 +111,16 @@ function createWindow() {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false,
additionalArguments:["sonusPort:"+global.sonusSocket]
},
};
if (externalDisplay) {
browserWindowOptions.x = width; //+ 2; //externalDisplay.bounds.x + 50
browserWindowOptions.y = height; //externalDisplay.bounds.y + 50
console.log(
"display size=" + browserWindowOptions.x + "+" + browserWindowOptions.y
);
if(debug)
console.log(
"display size=" + browserWindowOptions.x + "+" + browserWindowOptions.y
);
}

// Create the browser window.
Expand Down Expand Up @@ -148,6 +181,9 @@ function startSonus(port) {
if (config && config.speech && !firstRun) {
// get the sonus communications socket port
getPort({ port: getPort.makeRange(9000, 9500) }).then((port) => {
if(debug)
console.log("found port="+port)
//console.log("global="+JSON.stringify(global,null,2))
global.sonusSocket = port;
config.communications_port = port;
startSonus(config.communications_port);
Expand Down Expand Up @@ -216,10 +252,14 @@ if ((config.remote && config.remote.enabled) || firstRun) {
remote.on("relaunch", function (newConfig) {
console.log("Relaunching...");
// rebuild the html file plugin position info, from the NEW config data
// if pm2 is not being used for this process control
if (!usepm2) {
// recalc plugin info since something changed
loader.loadPluginInfo(__dirname + "/index.html", newConfig);
// force reload
app.relaunch();
}
// else die and pm2 will restart us
app.quit();
});
}
Expand All @@ -241,17 +281,18 @@ if (config.motion && config.motion.enabled) {

mtnProcess.stdout.on("data", function (data) {
var message = data.toString();
//console.log("motion message="+message)
if (message.startsWith("!s:")) {
console.log(message.substring(3));
//console.log(message.substring(3));
mainWindow.webContents.send("motionstart", true);
} else if (message.startsWith("!e:")) {
console.log(message.substring(3));
//console.log(message.substring(3));
mainWindow.webContents.send("motionend", true);
} else if (message.startsWith("!c:")) {
console.log(message.substring(3));
//console.log(message.substring(3));
mainWindow.webContents.send("calibrated", true);
} else if (message.startsWith("!E:")) {
console.log(message.substring(3));
//console.log(message.substring(3));
mainWindow.webContents.send("Error", message.substring(3));
mtnProcess.kill();
} else {
Expand Down
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "smart-mirror",
"version": "0.0.30",
"version": "0.0.31",
"description": "The fairest of them all",
"main": "main.js",
"scripts": {
"install": "bower install",
"start": "DISPLAY=\"${DISPLAY:=:0}\" electron main.js ",
"start": "DISPLAY=\"${DISPLAY:=:0}\" electron --disable_gpu main.js ",
"train-model": "electron scripts/train-model.js",
"sonus": "node sonus.js",
"motion": "sudo node motion.js",
Expand Down Expand Up @@ -33,29 +33,31 @@
"url": "https://github.com/evancohen/smart-mirror/issues"
},
"homepage": "https://github.com/evancohen/smart-mirror",
"devDependencies": {
"angular-i18n": "^1.8.2",
"bower": "^1.8.12",
"electron": "11.3.0",
"eslint": "^6.8.0",
"wiredep-cli": "^0.1.0"
"devDependencies": {
"eslint": "^6.8.0"
},
"dependencies": {
"bower": "^1.8.12",
"electron": "^27.0.2",
"@electron/rebuild": "github:electron/rebuild",
"@electron/remote": "^2.0.12",
"@fortawesome/fontawesome-free": "^6.2.0",
"@google-cloud/speech": "^4.2.0",
"@grpc/grpc-js": "^1.2.11",
"alphavantage": "1.2.6",
"alphavantage": "^2.5.0",
"angular-moment": "^1.3.0",
"angular-sanitize": "1.5.11",
"angular-i18n": "^1.8.2",
"annyang": "^2.6.1",
"cheerio": "^1.0.0-rc.5",
"electron-json-storage": "^4.4.0",
"electron-rebuild": "^1.11.0",
"express": "^4.17.1",
"fitbit-oauth2": "0.0.1",
"humanize-duration": "^3.25.1",
"hyperion-client": "1.0.3",
"jsonform": "git://github.com/jsonform/jsonform.git",
"jsonform": "git+https://git@github.com/jsonform/jsonform.git",
"moment": "^2.29.1",
"mqtt": "^5.3.3",
"pretty-ms": "^7.0.1",
"recorder": "git+https://[email protected]/sdetweil/recorder.git",
"rss-parser": "^3.12.0",
Expand All @@ -64,6 +66,7 @@
"spotify-web-api-node": "^5.0.0",
"waitprocess": "git+https://github.com/sdetweil/waitprocess.git",
"winston": "^3.3.3",
"wiredep-cli": "^0.1.0",
"youtube-api": "^3.0.1"
},
"eslintConfig": {
Expand Down
4 changes: 3 additions & 1 deletion plugins/autosleep/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(function () {
"use strict";

function AutoSleepService($interval, Focus) {
function AutoSleepService($interval, $rootScope, Focus) {
var service = {};
var autoSleepTimer;
service.woke = true;
Expand Down Expand Up @@ -55,6 +55,7 @@
// only wake up if sleeping
if (Focus.get() === "sleep") {
service.woke = true;
$rootScope.$broadcast("userPresence", "true")
switch (config.autoTimer.mode) {
case "monitor":
case "tv":
Expand Down Expand Up @@ -106,6 +107,7 @@
service.sleep = function () {
if (config.autoTimer.mode !== "disabled") {
service.woke = false;
$rootScope.$broadcast("userPresence", "false")
switch (config.autoTimer.mode) {
case "monitor":
case "tv":
Expand Down
14 changes: 13 additions & 1 deletion plugins/calendar/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
"type": "boolean",
"title": "{{showCalendarNames}}",
"default": false
},
"refreshInterval":{
"type":"integer",
"title":"{{refeshInterval}}",
"default":30,
"enum":[
15,
30,
45,
60
]
}
}
}
Expand Down Expand Up @@ -54,7 +65,8 @@
},
"calendar.maxResults",
"calendar.maxDays",
"calendar.showCalendarNames"
"calendar.showCalendarNames",
"calendar.refreshInterval"
]
}
],
Expand Down
8 changes: 5 additions & 3 deletions plugins/calendar/controller.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
function Calendar($scope, $http, $interval, CalendarService) {
function Calendar($scope, $rootScope, $http, $interval, CalendarService) {

var getCalendar = function(){
CalendarService.getCalendarEvents().then(function () {
$scope.calendar = CalendarService.getFutureEvents();
$scope.calendar=CalendarService.getFutureEvents()
if($scope.calendar)
$rootScope.$broadcast('calendar',$scope.calendar );
}, function (error) {
console.log(error);
});
Expand All @@ -13,4 +15,4 @@ function Calendar($scope, $http, $interval, CalendarService) {
}

angular.module('SmartMirror')
.controller('Calendar', Calendar);
.controller('Calendar', Calendar);
5 changes: 3 additions & 2 deletions plugins/calendar/locales/de.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"calendar": {
"config": {
"title": "Calendar Settings",
"title": "Kalendereinstellungen",
"URLs": "iCal-URLs",
"maxevents": "Maximale Anzahl von Ereignissen für alle iCals",
"maxdays": "Maximale Anzahl der anzuzeigenden Tage",
"showCalendarNames": "Aktivieren Sie diese Option, um Kalendernamen anzuzeigen"
"showCalendarNames": "Aktivieren Sie diese Option, um Kalendernamen anzuzeigen",
"refeshInterval": "Wie oft in Minuten aktualisiert werden soll, standardmäßig 30"
}
}
}
Loading