Further to my post here about updating labels, I have another question if I may.
The issue below occurs when the Blynk iOS app has been backgrounded for a period of time. It shows an old timer value (e.g. 13hrs 57mins). Then when Big Timer send itâs update every on the minute, the timer values suddenly show the latest value (e.g. 4hrs 45mins).
I want to understand how to keep them in sync with the actual timer values, rather than having to wait the minute for them to update.
My brains not working at the moment, I canât think whether I need a function in node red to push the data more frequently, or if I need to use a Blynk sync node of some sort.
I guess that there are lots of ways to achieve this, but my approach would be to save the current remaining time to a flow-level variable then retrieve it every second and write that result out to Blynk.
You can do this without writing any functions, just using the Change nodeâŚ
The Change node connected to Big Timer looks like this:
This is setting a flow-level variable called countdown1 to be equal to the current output from BigTimer on the msg.time element of the payload.
The timestamp node is set to repeat every second and triggers the second Change node which looks like this:
This node is retreiving the stored time and outputting it as msg.payload, which is then outputting to a debug node in this case, but youâd send it to Blynk.
Youâd obviously need different variables for each big timer, countdown1, countdown2 etc or countdown_kitchen, countdown_garden etc.
BTW, I discovered this little function the other day:
I think itâs a new utility in one of the recent releases (Iâm running Node-Red v0.20.5) which allows you to easily see flow and global variables, which can be handy for debugging.
@PeteKnight thanks for that info, Iâm sure it will come in handy. Also I did not notice the context data, Iâm also on 0.20.5, I really should read the release notes!
@gab.lau actually same here - another point to Android
It seems that whenever Android app is opened I get the âjuggling ballsâ and it syncs. iOS app does not appear to sync and just updates at the next minute mark.
So, it would appear that Blynk server is receiving the updated time, but the iOS does not read the latest time, it just waits for the next value to be âpushedâ. (I have background app refresh turned on, location access is âwhile using appâ, I will try âAlwaysâ).
Maybe I could use Peteâs solution to send the payload to a sync node (set to syncVirtual pin xxx)? I donât fully understand the sync nodes tbh.
The Sync node is like calling Blynk.syncVirtual(VPin) in code. It causes the corresponding BLYNK_WRITE function to fire.
In Node-Red the node is used to force the Blynk server to send its latest values to the corresponding Write Event node, so it wonât really help in this situation.
You could use the App Event node, which outputs âaconâ when the app is connected. This could be used instead of the time stamp inject node, to cause the current stored time to be outputted when the app connects, instead of once every second. More elegant than my sledgehammer approach
Thank you, from my understanding this is because it will only sync the on/off state (which remains unchanged in the âoffâ period), and the styled button parameter are not updated/syncâable?
Would that be considered a bit banger?
Looks like this was discussed here, I wonder if the âbackgroundâ command every got implemented?
The Sync node is about pulling current values from the server into Node-Red (or to your MCU if youâre using the Blynk.syncVirtual(VPin) equivalent), so doesnât really relate to synchronising the app.
After some testing it seems that the App Event node can be used to trigger Big Timerâs status output. This in turn updates the styled button via @gab.lau 's function linked to in the first post.
So opening the iOS app now updates the timer immediately The only time it goes out of sync is when the app is stopped for a while and started, then it updates on the next minute.
Make sure âNotify devices when app connectedâ is on in settings