MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. UjwalReddy267
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    U
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 6
    • Groups 0

    UjwalReddy267

    @UjwalReddy267

    0
    Reputation
    11
    Profile views
    6
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    UjwalReddy267 Unfollow Follow

    Latest posts made by UjwalReddy267

    • MMM-Face-Reco-DNN Adding New Person

      I have been using MMM-Face-Reco-DNN. Is it possible to train for one person and then add it to the pickle instead of training for all the people when I want to add a new person

      posted in Troubleshooting
      U
      UjwalReddy267
    • RE: Python in module

      @Bugsounet I tried giving the full path too, but it did not work
      The python script does work on its own, there are no errors in that file

      posted in Development
      U
      UjwalReddy267
    • Python in module

      I am trying to run a python code from my node helper file. But, it does not seem to be working
      Core file:

      Module.register("MMM-Rediscover",{
                      default: {loc: 'modules/MMM-Rediscover/images'},
      		count : 0,
      		files:[],
      		start : function(){
      				var self = this
      				self.sendSocketNotification("GET_FILES",self.config.loc)
      				setInterval(function() {self.updateDom()}, 3000);
      		},
      		getDom : function (){
                              var wrapper = document.createElement('div')
      			wrapper.id = 'GPHOTO'
      			var img = document.createElement('div')
      			var i = this.count
                              img.style.backgroundImage = 'url(' + this.files[i] + ')'
      			img.id = 'photo'
              		var blr = document.createElement('div')
      			blr.id = 'backgrnd'
      			blr.style.backgroundImage = 'url(' + this.files[i] + ')'
      			wrapper.appendChild(blr)
      			wrapper.appendChild(img)
      			len = this.files.length
      			this.count = (this.count == len-1) ? 0 : this.count+1
                              return wrapper
                      },
      		getStyles : function (){
      			return ['MMM-Rediscover.css']
      		},
      		socketNotificationReceived : function(notification , payload){
      			if(notification == "OBTAINED"){
      				this.files = payload
      			}
      		}
      })
      
      

      My node_helper file:

      var NodeHelper = require("node_helper")
      var file = require("fs")
      const spawn = require("child_process").spawn
      module.exports = NodeHelper.create({
      		start : function(){
      			var process = spawn("python", ["modules/MMM-Rediscover/images/Photos.py"])
      			process.stdout.on("data", (data)=>{console.log(data)})
      		},
      		socketNotificationReceived: function(notification, payload){
      			if(notification == "GET_FILES"){
      				var payload = this.getFiles(payload)
      				this.sendSocketNotification("OBTAINED",payload)
      			}
      		},
      		getFiles : function(loc){
      			const contents = file.readdirSync(loc)
      			ret = []
      			for ( var i = 0; i < contents.length; i++){
      				extension = contents[i].split('.').pop().toLowerCase()
      				if (extension == 'jpg'){
      					var currentItem = loc + '/' + contents[i]
      					ret.push(currentItem)
      				}
      			}
      			return ret
      		}
      })
      
      
      posted in Development
      U
      UjwalReddy267
    • RE: Help with updateDom()

      @sdetweil said in Help with updateDom():

      @UjwalReddy267 your pointer ‘this’ is wrong inside the timer handle

      setInterval(function() {this.updateDom()
      

      you need to do

      var self=this
      

      and in the handler use self instead

      setInterval(function() {self.updateDom()
      

      Yes, that was the error, thank you it works now.

      posted in Development
      U
      UjwalReddy267
    • Help with updateDom()

      This module is supposed to show a slideshow of the two images that are given in the variablle loc. But, I am not able to update the Dom. It does not change the image. The setInterval function does not seem to be working.

      Module.register("MMM-Test",{
                      default: {loc: ["modules/MMM-Test/test1.jpg","modules/MMM-Test/test.jpg"], count:0},
      		start : function(){
      				setInterval(function() {this.updateDom()}, 1000);
      		},
      		getDom : function (){
                              var wrapper = document.createElement('div')
      			wrapper.id = 'FULL'
      			var img = document.createElement('div')
      			var i = this.config.count
                              img.style.backgroundImage = 'url(' + this.config.loc[i] + ')'
      			img.id = 'photo'
              		var blr = document.createElement('div')
      			blr.id = 'backgrnd'
      			blr.style.backgroundImage = 'url(' + this.config.loc[i] + ')'
      			wrapper.appendChild(blr)
      			wrapper.appendChild(img)
      			this.config.count = (this.config.count + 1) % 2
                              return wrapper
                      },
      		getStyles : function (){
      			return ['MMM-Test.css']
      		}
      })
      
      posted in Development
      U
      UjwalReddy267