"Originally" I had a bit of flow that looked at MQTT messages when devices connect to the WiFi network.
This is what I get:
{"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"fb4161b2.ecdcf","time":"2019-4-16 16:48:25","ttl":0,"_queuetimestamp":1555397305156,"queueCount":1}
Now, a few days ago it was ok.
Then, while working on something else, and the machine locked up, then when I got it working again it didn't work.
The switch
node worked with something like the message.
Then to get it working I had to change the switch
node settings from what ever they were to this:
(msg.)payload["IP Address"]
In the property field.
And it worked, weirdly.
Today I reluctantly after finding out about node-red --safe
I sat down and did the hard yard loading the flow which caused the problem.
Edited the offending part and what ever.
It is now working.
But here it gets interesting.
The WiFi connected part of the flow stopped working.
I also had to edit a function node from what it was to this:
var mpayload = msg.payload;
var mtopic = msg.topic;
var name = context.get('name');
var count = context.get('count') || 0;
if (mtopic === 'STATUS/WIFIDEVICEID')
{
//
//node.warn("Name recived is " + msg.payload["WIFI-DEVICE"]);
context.set('name', msg.payload["WIFI-DEVICE"]);
count = 1;
context.set('count',count);
node.status({fill:"yellow",shape:"dot",text:"WiFi Device received"});
}
if (msg.payload === 'On-line')
{
//
if (count === 1)
{
//
node.status({fill:"green",shape:"dot",text:"message modified"});
msg.topic = name;
return msg;
}
return msg;
}
if (msg.payload === 'Off-line')
{
//
node.status({fill:"red",shape:"dot",text:"Off Line"});
count = 0;
context.set('count',count);
return msg;
}
Note the line(s):
//node.warn("Name recived is " + msg.payload["WIFI-DEVICE"]);
context.set('name', msg.payload["WIFI-DEVICE"]);
Now, I am not getting something - again.
It was working.
I didn't change anything to do with this and suddenly it stopped working.
It did work a week ago. In that time the machine had the big crash and I had to spend a lot of time getting it working again.
Now I have to change things back to what they were before. (A week ago)
I made the line (from the function
node) to:
context.set('name', msg.payload["WIFI_DEVICE"]);
And the switch from:
(msg.)payload["IP Address"]
In the property field.
to payload.IP_Address
Why is this happening?