Is there a way to somehow see what is updating an object in global context?
I am pretty sure there is not. But is there another way to monitor IF and WHEN an object is changing? Any kind of dirty hack is fine. Right now I have used inject node set to 1s to a function that writes the object to a file, but I need the resolution to be faster than 1s as I think there's a timing glitch in my dodgy programming.
I'll explain why here:
I use global context quite a lot to store information about the state of something external. In this case, it's an audio amp that is being polled periodically over RS232, to see if its settings were updated externally (i.e. from the amplifer or one of the many keypads around the house).
When the device responds to my request, I store the response in global context THEN pass a message to another flow that reads it from context and updates a Template UI node so I can see e.g. volume etc. from the dashboard.
Yes I know this sounds absurd, but my reasons (e.g. for not using MQTT and persistence to do something similar) are as follows - there is undoubtedly fault to my reasoning and I'm open to hearing about that!
- it's my way of being able to design a different UI later without having to remember what format the message comes in, etc.
- I like to be able to diagnose problems after a power outage, server reboot, etc.
- Also if the device hasn't been polled for a while, and I want some external display to reflect its latest status, I just need to get that display to query the context store and I can be confident it will be up to date (ok maybe MQTT persistence can do this - but can it after a server reboot?)
- I like to be able to use the context browser to see everything in one place, and it works nicely for me
- I like to add metadata such as "time updated" and additional settings e.g. zone names that don't come through from the original RS232 message...
Here's my actual problem. In the above screenshot you can see "volume" is a number. It comes in over RS232 as a string with leading zero. I use parseInt() to convert it before storing it to global context.
But sometimes, every so often, my Template UI is updated with the string, causing it to empty the data passed to the slider, and the display kind of flashes around.
I'm convinced the best way to resolve this is to somehow monitor to see if this is a timing issue caused by my code that writes to global context, or a timing issue caused by my code that reads and updates the display...