Sfoglia il codice sorgente

fix node name undefined

Luigi Cisana 7 anni fa
parent
commit
e581364e25
1 ha cambiato i file con 9 aggiunte e 2 eliminazioni
  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 = {};