i do not want to look at an empty image error placeholder when the incoming signal quality is not 'Good'. so i built the following binding on a custom prop isOn. the idea being if the signal stinks, i can look at a nice image telling me that. when it comes back online, i can then view the relevant switch states. problem is, this isn't working. i'm still seeing things that make me cry:
here's the code i bound to the image source (bear in mind isOn is a custom prop bound to a Tag's boolean flag):
def transform(self, value, quality, timestamp): #<-- from isOn prop
if quality != 'Good':
return '/system/images/development/btn_noSIG.svg'
elif value:
return '/system/images/development/btn_ON.svg'
else:
return '/system/images/development/btn_OFF.svg'
the Binding Preview evaluates successfully AND correctly. but my eyes are still accosted when i load the page. what am i missing here?
there's only TWO places i don't care about speed: Government Policy Making by Idiots and just about anything where i'm naked. so i have some Christmas reading ahead of me.
sorry. had to modify the solution, because it doesn't work as constituted. so i just modified it so it reflects both the driving state (from the Tag) that determines if it shows the NO-SIG, and the subsequent flag needed to populate ON//OFF.
ALL credit goes to @Transistor because the original post is his, i just modified it to behave correctly. plus i also got to learn about expressions in a way i never knew before. all around making me a better wunderkind.
it still fails when it goes offline, dammit, but i don't know what to do about that right now. the NO-SIG image should load, but it doesn't... and i don't know what to chase down. in theory, we're done here, i guess.
HAVE A MERRY CHRISTMAS YOU FABULOUS REPROBATES!!
God bless and keep you. I'll be back in the New Year.
just a quick edit. this solution feel somewhat flakey in that the browser/HMI needs refreshing a couple times before it displays properly. so i'm thinking it's a cache thing, which is out of scope here. but for those that follow: clear your caches!
EDIT: this also applies when the device goes offline. it reverts to the eyesore red box until you refresh the browser/HMI. very odd.