Hi!
Firstly, thanks to all you guys for sharing your knowledge, I'm sure there are many lurkers like myself who benefit so much from this forum.
I've been working on an OH 2.5 system running on a RPi2 relying heavily on Node-RED as a rule engine for a while now, and have generally gotten by searching for similar "help me!!" posts, however this one has me stumped! I have no experience of coding, or even Linux other than what I have picked up along the way.
My latest aim is to integrate phone battery level into my presence detection flow, which currently relies solely on checking for a wifi connection, to reduce nuisance switching (and upsetting my wife) should a wifi connection drop due to both batteries running out.
I am sending battery percentage as part of a string (level, power connected, timestamp) through MQTT from each phone, which then updates the corresponding OpenHAB item. I then want to check this item during the presence detection flow so that it only continues if the last received number was higher than x.
The payload is:
{"level":6,"isPlugged":false,"timestamp":1581370521414}
Brace yourselves for a silly question... I am currently using:
msg.payload = msg.payload.split('level')[1].substr(2,2);
return msg;
Within a function node to extract the number I want from the payload, however from my understanding, this is will pass 2 numbers, and 2 numbers only, so should the battery be at 100% or below 10%, the flow breaks. Is there a way that I can extract either 1, 2 or 3 digit numbers?
Sorry for the long winded simple question, I feel context is important.
While I am appeasing the wife.....
Whenever I restart Node-RED, several of my flows trigger. Would this be a persistence issue or is there a setting somewhere that I've missed to stop that happening?