Node-RED 0.20.0-beta.2 released

OK - that was to do with the spacer (now fixed in 2.12.1) - Paul's issue is to do with using {{ }} syntax to set the labels. Don't think they are the same ???

Sorry, my bad - too much wine :smile:

1 Like

@zenofmud - thanks... found it.. fix pushed as dashboard 2.12.2

1 Like

Woow, It seems to have some great work here, I cannot wait for the non-beta, any idea of a date for it ? We'll have a tag beta on docker for this version ?

sorry if this has already been said, but I did not find the information

Thanks.

No plans yet for a docker beta; the automation we have to produce the docker images doesn't pickup beta releases. Not got time at the moment to figure out how to change that.

1 Like

@TotallyInformation that spacing is no worse or better than any other node:

Local_Node-RED

I think that length of text only just tips over the grid size, so the whitespace looks larger than it might, but is entirely consistent.

OK, thanks Nick. I've just not noticed it before. Move obvious with the link out node.

thank you! node-level comments/info is excellent!

hiding node-labels - also very handy

and import/export from/to file -- essential

and thanks for adding the enhanced error handling on Import - will make it much easier to debug copy/paste errors in workshops

1 Like

Hi @knolleary, Hope you had a good break?

I'm not sure if this is a bug in the beta or not.

I have a function node that uses global.get to get an object variable. I then update the local variable using Object.assign to merge another object. I don't write the global variable back but none-the-less, it is updated!!!

Didn't expect that! Just wasted a few hours before I realised what was happening.

// Allow this fn to use a global variable so that it doesn't
// have to be tied to the controller http get
const data = global.get('wiserAll') || msg.payload

if ( ! data.hasOwnProperty('HeatingChannel') ) {
    node.error('Input data does not appear to be from the Wiser Controller - check the input')
    return
}

// Get saved room temperature/humidity values to enhance data
const hSensors = global.get('currentHumidities')
const tSensors = global.get('currentTemperatures')

// Get the list of rooms
const roomDetails = global.get('rooms', 'file')

// Walk through each room
for ( let room in roomDetails ) {
    
    // Find Wiser room
    // TODO: Move the filter function outside the loop
    let wr = false
    if ( data.hasOwnProperty('Room') ) {
        wr = data.Room.filter(item => {
            let r = false
            if ( (room === item.Name.trim()) ) r = true
            if ( item.Invalid === 'NothingAssigned' ) r = false
            return r
        })[0]
        
    }
    // If we found it, merge the data
    if ( wr ) {
        wr.Name = wr.Name.trim()
        Object.assign(roomDetails[room], wr) // merge wr into the room object (requires Node.js 4+)
    } else {
        // Not in the Wiser controller but we still need some data
        roomDetails[room].id = room.replace(' ', '_')
        roomDetails[room].Name = room
    }
    
} // --- end of room loop --- //

// Add Overall System Demand Data
roomDetails.demand = {}
roomDetails.demand.lastUpdate                   = new Date()
roomDetails.demand.PercentageDemand             = data.HeatingChannel[0].PercentageDemand
roomDetails.demand.DemandOnOffOutput            = data.HeatingChannel[0].DemandOnOffOutput
roomDetails.demand.HeatingRelayState            = data.HeatingChannel[0].HeatingRelayState
roomDetails.demand.IsSmartValvePreventingDemand = data.HeatingChannel[0].IsSmartValvePreventingDemand

// Add a last updated timestamp
roomDetails.lastUpdate = new Date()

return {'topic': msg.topic, 'payload': roomDetails}

Well, that was interesting. I tried 3 things other than a straight assign, of which only 2 work - all 3 should work as far as I can see:

const roomDetails1 = global.get('rooms', 'file')   // <== DOESN'T WORK
const roomDetails2 = Object.assign({}, global.get('rooms', 'file'))   // <== DOESN'T WORK but should, it creates a shallow clone.
const roomDetails3 = JSON.parse(JSON.stringify(global.get('rooms', 'file')))  // <-- Does work
const roomDetails4 = RED.util.cloneMessage(global.get('rooms', 'file'))  // <-- Does work

@TotallyInformation Object.assign is not suitable for deep cloning an object, as explained here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Deep_Clone

OK, but I still didn't expect something that should need a getter to get hold of to be updated in my function node?! I didn't write it back with a set.

This has been discussed a few times, both here and on the old google group as it isn't a new thing. Javascript passes by reference and the in-memory context doesn't clone objects whenever you get them. So these things can happen.

That's how it has been ever since we introduced the get/set functions. We should probably look at that again - although adding the clone in will have a performance impact, and break flows that, against all documentation and advice, take advantage of that particular behaviour.

OK, thanks - I know about the cloning issue but didn't realise it would bite me when doing a global.get as I've never seen that happen before. Only seen problems with msg.

It would certainly be more consistent and a lot more robust if the getters did a clone since I think that is what everyone would expect.

The msg issue is different and I agree there is no easy way to fix that without significant overheads - that's less of an issue to me at least & you already have a utility function and some work arounds to deal with the issue.

But there is no information about this being an issue with the global/flow/context getters and the utility function implies that it is specific to the msg object (though clearly that isn't quite true).

2 issues : 1. I was using node-red-contrib-postgres (version 0.6.1) with the node-red version 0.19.0 and everything was working fine. After installing Node-red beta-3 that postgres node started giving errors :

  • "Cannot find C:\Users\Vishal\AppData\Roaming\npm\node_modules\node-red\red\red"

  • in command prompt while starting node-red : [node-red-contrib-postgres/PostgreSql] Error: Cannot find module './lib/red.js'

second problem is in web-sockets : While using worldmap node other websockets gets disconnected after first deploy. I have listed that detailed problem to the owner of world map on github. He said that the problem was with node-red and it is solved in beta version. I used beta version and the problem still persist. here is the link of that detailed discussion : https://github.com/dceejay/RedMap/issues/65

youā€™ve posted this on the beta2 announcement not the beta3

Problem will still remain same.. But still thanks.. I'll post it on beta 3...