I am still struggling a bit with the details of the matchingKeys.forEach part.
I would like to add the msg.payload.Time to the payload of each element.
My first approach is
const matchingKeys = Object.keys(msg.payload).filter((element) => element.startsWith("ATC"))
matchingKeys.forEach((element) => node.send({
topic: "tele/xiaomi/" + element,
payload[element].Time: msg.payload.Time, //error message: No value exists in scope for the shorthand property 'payload'. Either declare one or provide an initializer.(18004)
payload: msg.payload[element],
}))
I was thinking that I added the sub property to the element's payload and then made the node out payload the extended payload.
I thought that maybe I first have to initialize the message property msg.payload[element].Time because it is not known to the system yet.
So I tried
const matchingKeys = Object.keys(msg.payload).filter((element) => element.startsWith("ATC"))
matchingKeys.forEach((element) => node.send({
topic: "tele/xiaomi/" + element,
msg.payload[element].Time = msg.payload.Time,
payload: msg.payload[element],
}))
This should create a property "Time" in each payload of each element. Well, at least that is what I thought ![]()
What am I doing wrong? Or where is my mental mistake? I am not altering the original payload, only the element specific one. That should be fine in my books ![]()
I keep seeing a yellow lightbulb or a red triangle but those seem to only say "something is wrong" and are giving absolutely no indication of what. Seems somehow useless to me.
Sometimes I can hover with the mouse over each part of the respective line of code but this time I don't even see anything there.
Obviously the system dislikes something but is not sharing with me what it is ![]()