I wanted to call attention to a label when the value it is displaying changes, so I made its background flash red a couple of times.
For that I used 2 variables. One is bound to the same device that provides the label content, and has the following script on ValueChanged:
App.SetDeviceAttribute(“Color1”,"#ffb3b3");
sleep(1000);
App.SetDeviceAttribute(“Color1”,"#FFC0C0C0");
sleep(1000);
App.SetDeviceAttribute(“Color1”,"#ffb3b3");
sleep(1000);
App.SetDeviceAttribute(“Color1”,"#FFC0C0C0");
Then had the Background of the label bound to Color1.
Is there a better way to do this?
Can a ValueChanged script be attached to an actual device, or a label? Or only to a variable inside a virtual device?
The other thing I’ve found is that the ValueChanged script runs once when starting the app. I guess because the value changes from null to DefaultValue.
EDIT: as a possible add-on, I’m thinking of using a 3rd variable to hold the old value. And then compare it with the current to decide if flashing in red or green depending if it went up or down (for energy monitoring).