I'm way above my head here in javascript but why does this not put neither the "tidsPunkt" nor the msg.payload into rommet.profil[dag] ?
if (rommet.hasOwnProperty("profil") === false) {
rommet.profil = {};
}
var returnedObject = Object.assign(rommet.profil, {[dag]: {[tidsPunkt]: msg.payload}});
Norwegian dictionary:
Rommet = the room
Dag = day
Tidspunkt = time
Profil = profile
Via an RBE node I’m trying to save every new setpoint of several rooms in a profile object from another (KNX RF) system. (I’m also rounding the times to nearest quarter of an hour).
Why? Because I’m going to ramp the collection of points according to room heating coefficient so my main system is not taken by surprise each time a setpoint suddenly jumps or falls.
To add a new object (i assume that is what you want, not sure as there is context missing) you don't need to use Object.assign. Object.assign wil clone the object, unless that is what you want.
There is a node to emulate a ramping thermostat. that includes hysteresis, perhaps that could help ?
rommet is copied from part of the nested context data.
I guess Object.assign is not needed (certainly not the cloning part) as it didn't do what I thought with regards to merging. Went back to rommet.profil[dag][tidsPunkt] = msg.payload after checking for existence of all levels of nesting.
I am actually going to use that contrib-node, but I want to set the profiles dynamically from that other heating system (on a weekly delay obviously).
Yes, I know. I garble my sentences in English sometimes. I meant that I want automatically retrieve and dynamically store new setpoints in different daily profiles per room in that node vs just manually copying over setpoints to that node.