David Sanner - Can a notification state get up...

Can a notification state get updated before its associated path value is updated?
Seems backwards but when I get a notification for a path entering a zone and I print that path's value via app.getSelfPath(somePath.value) it hasn't been updated.
So notification.somePATH.state can change before somePath.value has been updated to the value for the corresponding zone/notification.
7 Replies
Teppo Kurki
Teppo Kurki3mo ago
In a plugin?
David Sanner
David SannerOP3mo ago
Yes, the plugin is subscribed to notifications.* / instant and when processing a notification event I check the corresponding value via app.getSelfPath and it doesn't seem to have been updated yet. A little more testing: in my function that handles notifications that have been subscribed to, if I wrap getSelfPath like this: setTimeout(function() {val = app.getSelfPath(somePath).value }, 0) I get the proper value (the one that is in the zone that triggered notification.somePath). Otherwise I get the value before the path entered the zone.
eg. "path": "electrical.batteries.bmv.relay" When I enable the relay the associated zone triggers a notification but when I check the value via app.getSelfPath(selectrical.batteries.bmv.relay).value I get 0 (unless I wrap the call as shown above) I guess since setTimeout is asynchronous it's allowing other sk server code to execute ... so that the path value gets updated??
Teppo Kurki
Teppo Kurki3mo ago
Exactly. Was going to suggest nexttick in your code to allow the value to be updated But i think we should fix the zones processing, so that the new value is there when the notification is sent
David Sanner
David SannerOP3mo ago
Nice... just coded w/ nextTick which does the same async trick but it does make sense the the value triggering a notification would get updated first. Thx, good to know I wasn't "seeing things"
Teppo Kurki
Teppo Kurki3mo ago
Want to create an issue lest we forget the proper fix?

Did you find this page helpful?