diff --git a/devices/device.js b/devices/device.js index 4ae8d695..87b280a5 100644 --- a/devices/device.js +++ b/devices/device.js @@ -2053,13 +2053,6 @@ module.exports = function (RED) { }); } - // Copy the command original params to the payload - /*Object.keys(original_params).forEach(function (key) { - if (!Object.prototype.hasOwnProperty.call(msg.payload, key)) { - msg.payload[key] = original_params[key]; - } - });*/ - me.send(msg); } @@ -2859,19 +2852,15 @@ module.exports = function (RED) { updateState(from_states) { const me = this; let modified = []; - // me._debug("CCHI updateState state_types " + JSON.stringify(me.state_types)); me._debug('updateState current state ' + JSON.stringify(me.states)); Object.keys(me.state_types).forEach(key => { if (Object.prototype.hasOwnProperty.call(from_states, key)) { - // console.log("CCHI found key " + key); let o_modified = me.setState(key, from_states[key], me.states, me.state_types[key]); if (o_modified) { me._debug('.updateState set "' + key + '" to ' + JSON.stringify(from_states[key])); modified.push(o_modified); } - // console.log("CCHI set " + key + " val " + JSON.stringify(current_state[key])); } - // else console.log("CCHI NOT found key " + key); }); let thermostat_modified = false; if (modified.includes("thermostatTemperatureSetpoint")) { @@ -2948,8 +2937,6 @@ module.exports = function (RED) { }; } const exclusive_states = state_type.exclusiveStates || []; - // console.log("CCHI ---> setState key " + JSON.stringify(key) + " v " + JSON.stringify(value) + " ov " + JSON.stringify(old_state) + " st " + JSON.stringify(state_type) + " ex " + JSON.stringify(exclusive_states)); - if (value == null) { if (state_type.type & Formats.MANDATORY) { me.error("key " + key + " is mandatory."); @@ -3099,7 +3086,6 @@ module.exports = function (RED) { } }); mandatory_to_delete.forEach(ikey => { - // console.log("CCHI try removing " + ikey); let exclusive_state_found = false; exclusive_states.forEach(e_state => { if (typeof state[e_state] !== 'undefined') { @@ -3134,7 +3120,6 @@ module.exports = function (RED) { } } else { new_state = Formats.formatValue(key, value, state_type.type & Formats.PRIMITIVE, state_type.defaultValue); - // console.log("CCHI checking new_state " + key + " " + new_state + " type " + JSON.stringify(state_type)); if (state_type.min !== undefined && new_state < state_type.min) { me.error('key "' + key + '" must be greather or equal than ' + state_type.min); new_state = undefined; @@ -3153,7 +3138,6 @@ module.exports = function (RED) { } } if (new_state !== undefined && !(state_type.type & (Formats.OBJECT | Formats.ARRAY))) { - // console.log("CCHI Update state for " + key + " to " + new_state); if (old_state !== new_state) { differs = key; } @@ -3162,7 +3146,6 @@ module.exports = function (RED) { if (new_state !== undefined && exclusive_states.length > 0) { exclusive_states.forEach(rkey => delete state[rkey]); } - // console.log("CCHI END ----> " + key + " = " + JSON.stringify(state[key])); if (Array.isArray(differs)) { let o_differs = {}; o_differs[key] = differs; diff --git a/lib/SmartHome.js b/lib/SmartHome.js index bdbda4be..6e6520fc 100755 --- a/lib/SmartHome.js +++ b/lib/SmartHome.js @@ -184,7 +184,7 @@ class GoogleSmartHome { let all_urls = [me.Path_join(me._httpPath, 'token')]; let to_remove = []; - REDapp._router.stack.forEach(function (route, i/*, routes*/) { + REDapp._router.stack.forEach(function (route, i) { if (route.route && ( (route.route.methods['get'] && get_urls.includes(route.route.path)) || (route.route.methods['post'] && post_urls.includes(route.route.path)) || @@ -193,7 +193,6 @@ class GoogleSmartHome { )) { me.debug('SmartHome:Stop(): removing url: ' + route.route.path + " registered for " + me.GetRouteType(route)); to_remove.unshift(i); - // routes.splice(i, 1); } }); to_remove.forEach(i => REDapp._router.stack.splice(i, 1)); @@ -246,23 +245,16 @@ class GoogleSmartHome { me._localUDPServer.on('message',function(msg,info){ const data = msg.toString(); - // me.debug('Sevice Scan UDP server received ' + msg.length + ' bytes from ' + info.address + ':' + info.port ); if (data === me._localScanPacket) { - // const sync_res = Buffer.from(JSON.stringify({clientId: me._nodeId}), 'utf8'); - // const sync_res = JSON.stringify({clientId: me._nodeId}); - // me.debug("Sending response message " + sync_res); me._localUDPServer.send(sync_res, info.port, info.address, function(error){ if(error){ me.debug("Sevice Scan UDP server error sending message " + error); - // }else{ - // me.debug('Sevice Scan UDP server data sent'); } }); } else { - // me.debug('Sevice Scan UDP server data received : ' + data); me.debug("Sevice Scan UDP server error wrong message received!"); } }); @@ -270,10 +262,8 @@ class GoogleSmartHome { me._localUDPServer.on('listening',function(){ const address = me._localUDPServer.address(); const port = address.port; - // const family = address.family; const ipaddr = address.address; me.debug('Sevice Scan UDP server listening on: ' + ipaddr + ':' + port); - // me.debug('Sevice Scan UDP server family: ' + family); }); me._localUDPServer.on('close',function(){