I'm going over old code and updating things.
This has me not getting anywhere just now.
code:
//const time_ = new Date().toLocaleString()
const time_ = new Date().toLocaleString('en-AU', { hour12: false })
let Modem = context.get('Modem')||0
//node.warn(msg.device)
if (msg.device == "ROUTER")
{
//node.warn("Modem test")
//node.warn("Status is " + msg.payload) // Number if pinged.
//if (msg.payload == "Line Good")
if (msg.payload > 0)
{
context.set('Modem',1)
node.status({fill:"yellow",shape:"dot",text:"Modem Seen"})
msg = {payload: 'Online',device:'Modem',who:global.get("myDeviceName"),time:time_}
//
// Construct msg.payload to say modem seen and message from TelePi.
//
return msg
}
else
{
context.set('Modem',0)
node.status({fill:"black",shape:"dot",text:"Modem NOT Seen"})
msg = {payload: 'OffLine',device:'Modem',who:global.get("myDeviceName"),time:time_}
//
// Construct msg.payload to say modem not seen and message from TelePi.
//
//msg = 0
return msg
}
}
if (msg.device == "UPLINK")
{
if (Modem == 1)
{
if (msg.payload > 0)
{
node.status({fill:"green",shape:"dot",text:"UpLink Ok"})
msg = {payload: 'Online',device:'UpLink',who:global.get("myDeviceName"),time:time_}
// node.warn("*********** uplink good **********")
//
// This needs modifying to say it is from TelePi.
//
return msg
}
else
{
node.status({fill:"red",shape:"dot",text:"UpLink Down"})
msg = {payload: 'Offline',device:'UpLink',who:global.get("myDeviceName"),time:time_}
//
// This needs modifying to say it is from TelePi.
//
return msg
}
}
else
{
node.status({fill:"grey",shape:"dot",text:"Unknown"})
context.set('MODEM',0)
//
// This needs modifying to say it is from TelePi.
//
msg = {payload:'UNKNOWN',device:'Uplink',who:global.get("myDeviceName"),time:time_}
return msg
}
}
I am not getting to see the line node.status({fill:"green",shape:"dot",text:"UpLink Ok"})
reflected on the node.
It is Stuck on Modem seen
message.
On the screen shot you can see on the right that Modem
is set to 1
.
And on this you can see the uplink good
message. (Now commented out)
yet, the node.status
is remaining at the Yellow state.
Now, ok, just thought of it:
Maybe the order in which the messages are received.
Shall check that.
But again: to prevent Sod's law happening, I'll ask here first.