Bladeren bron

fix node name undefined

Luigi Cisana 8 jaren geleden
bovenliggende
commit
e581364e25
1 gewijzigde bestanden met toevoegingen van 9 en 2 verwijderingen
  1. 9 2
      ramp-thermostat/ramp-thermostat.js

+ 9 - 2
ramp-thermostat/ramp-thermostat.js

@@ -13,8 +13,15 @@ module.exports = function(RED) {
   
   function RampThermostat(config) {
     RED.nodes.createNode(this, config);
-        
-    var node_name = this.name.replace(" ", "_");
+    
+    this.warn(node_name+" - "+JSON.stringify(this));
+    
+    var node_name;
+    if (typeof this.name !== "undefined" ) {
+      node_name = this.name.replace(" ", "_");
+    } else {
+      node_name = this.id;
+    }
     var globalContext = this.context().global;
     this.current_status = {};
     this.points_result = {};