Skip to content

Commit

Permalink
fixing some issues with moment
Browse files Browse the repository at this point in the history
  • Loading branch information
nischi committed Jul 8, 2019
1 parent ca0b678 commit 27f3cee
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions MMM-MotionControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* MIT Licensed.
*/

require('moment');

Module.register("MMM-MotionControl",{
defaults: {
delay: 15000,
Expand All @@ -18,6 +16,10 @@ Module.register("MMM-MotionControl",{

timeout: null,

getScripts: function() {
return ["moment.js"];
},

start: function() {
var self = this;

Expand All @@ -30,11 +32,10 @@ Module.register("MMM-MotionControl",{

inOnTime: function() {
var inOnTime = false;
var today = moment().startOf('day');
this.config.ontime.forEach(time => {
var split = time.split('-');
var from = today.add(split[0].substr(0, 2), 'h').add(split[0].substr(2, 2), 'm');
var to = today.add(split[1].substr(0, 2), 'h').add(split[1].substr(2, 2), 'm');
var from = moment().startOf('day').add(split[0].substr(0, 2), 'h').add(split[0].substr(2, 2), 'm');
var to = moment().startOf('day').add(split[1].substr(0, 2), 'h').add(split[1].substr(2, 2), 'm');

if (moment().isBetween(from, to)) {
inOnTime = true;
Expand All @@ -46,7 +47,7 @@ Module.register("MMM-MotionControl",{

notificationReceived: function(notification, payload, sender) {
if (this.inOnTime()) {
_self.sendNotification('CECControl', 'on');
this.sendNotification('CECControl', 'on');
} else {
if (this.config.useFacialRecognitionOCV3 === true) {
this.handleFacialRecognitionOCV3(notification, payload, sender);
Expand Down

0 comments on commit 27f3cee

Please sign in to comment.