I'm wondering why I don't have access to the msg object. As you can see in the attachment, the object exists and is populated.
For example, when I try to output “msg.payload.outHumidity” in a function, I get “undefined.” I don't understand this.
I'm wondering why I don't have access to the msg object. As you can see in the attachment, the object exists and is populated.
For example, when I try to output “msg.payload.outHumidity” in a function, I get “undefined.” I don't understand this.
More info is required, can you export you example flow.
Then post here following these instructions
In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)
```
code goes here
```
You can edit and correct your post by clicking the pencil
icon.
See this post for more details - How to share code or flow json
what does this mean? how are you "outputting" this?
where is that debug message coming from - before the function or after it? (i.e. what creates that data)
if you want to use msg.payload.outHumidity in the function then you can just do so:
const outHumidity = msg.payload.outHumidity
const inHumidity = msg.payload.inHumidity
const outHumidityNum = +outHumidity
const inHumidityNum = +inHumidity
node.warn({
outHumidity,
outHumidityNum,
inOutHumidityDiff: outHumidityNum - inHumidityNum
})
Here is the docs for working with functions: Writing Functions : Node-RED