giuseppeg88 / node-red-contrib-thermostat-scheduler

The Ultimate Node-RED Thermostat for Home Assistant - A NEST style thermostat with: temperature week scheduler, countdown and manual mode
GNU General Public License v3.0
66 stars 28 forks source link

TypeError: Cannot read properties of undefined (reading 'selector') #19

Open Christian-Schou opened 2 years ago

Christian-Schou commented 2 years ago

Hi

Thank you for this great integration in Node-Red. When I open up the dashboard I get the following error in my console:

TypeError: Cannot read properties of undefined (reading 'selector') at :57:37 at m.$digest (app.min.js:174) at m.$apply (app.min.js:177) at app.min.js:589 at Socket.t (app.min.js:590) at Socket../node_modules/component-emitter/index.js.Emitter.emit (index.js:145) at Socket.emit (typed-events.js:46) at Socket.emitEvent (socket.js:258) at Socket.onevent (socket.js:245) at Socket.onpacket (socket.js:209)

From what I can read it should be related to this code on the settings page:

function selec(val,sta) { var w="#td"+val+ID; if (sta) $(w).css('background-color','#4CAF50'); else $(w).css('background-color','#FFC107'); }

(function(scope){
    scope.ID = ID;
    scope.send({payload: '29'})
    scope.$watch('msg', function(msg) {
        selec(last,0); last=msg.selector; selec(last,1);
        for (var x=0; x<24; x++) 
            { 
                var w="#t"+x+ID; bar(w,msg.timing[((msg.days-1)*24)+x].toFixed(1)); 
                var v="#v"+x+ID; $(v).text(msg.timing[((msg.days-1)*24)+x].toFixed(1)+"°")
            } 
        for (var x=0; x<2; x++) { var w="#s"+x+ID; $(w).text(msg.timing[168+x].toFixed(1)+"°"); }
         $("#d0"+ID).text(thedays[msg.days-1]);
         if ((last>4) &&(last<29))
             $("#current"+ID).text(msg.timing[((msg.days-1)*24)+last-5].toFixed(1) + "°");
         else
             $("#current"+ID).text("-");

        if (msg.foryou!="") { stat(msg.foryou);  }

    });

})(scope);

Any clues what might go wrong?