Blynk / Node Red / Big Timer - refresh issue

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. :thinking:

Any tips appreciated!

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:
image

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:
image
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:

image
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.

Pete.

1 Like

This problem does not happen with the Android app :slight_smile:

Today I reopened the example project, done for the other topic, and the time on the button is updated

1 Like

@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 :smile:
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 :slightly_smiling_face:

Pete.

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? :smile:

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.

Pete.

2 Likes

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 :smile: 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 :man_facepalming:

Thanks @PeteKnight for the hint :+1: