simple fix catch the error caused by empty db return
eg.
[{"id":"bfc7d213.f19168","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"set","p":"payload[0].available","pt":"msg","to":"$count(payload) < 1 ? 0 : payload[0].available","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":940,"wires":[["ebc37340.ddfd9","af19c8b9.373f08"]]},{"id":"6b2ccd77.4da4cc","type":"function","z":"5a245aa1.510164","name":"simulate bad result from db","func":"msg.payload = [];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":880,"wires":[["af19c8b9.373f08","bfc7d213.f19168"]]},{"id":"ebc37340.ddfd9","type":"ui_gauge","z":"5a245aa1.510164","name":"Available Hand Sanitizer Dispenser 1","group":"8b5cde76.edd58","order":3,"width":"6","height":"6","gtype":"wave","title":"Available Hand Sanitizer","label":"ml","format":"{{msg.payload[0].available}}","min":0,"max":"3000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"500","seg2":"1500","x":760,"y":940,"wires":[]},{"id":"af19c8b9.373f08","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":820,"wires":[]},{"id":"c45993.1bd30e7","type":"inject","z":"5a245aa1.510164","name":"bad request","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":880,"wires":[["6b2ccd77.4da4cc"]]},{"id":"2385f349.ef9804","type":"inject","z":"5a245aa1.510164","name":"set level 1100","props":[{"p":"payload[0].available","v":"1100","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":320,"y":1020,"wires":[["ebc37340.ddfd9"]]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
or
[{"id":"c45993.1bd30e7","type":"inject","z":"5a245aa1.510164","name":"bad request","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":940,"wires":[["6b2ccd77.4da4cc"]]},{"id":"6b2ccd77.4da4cc","type":"function","z":"5a245aa1.510164","name":"simulate bad result from db","func":"msg.payload = [];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":940,"wires":[["ebc37340.ddfd9","af19c8b9.373f08"]]},{"id":"ebc37340.ddfd9","type":"ui_gauge","z":"5a245aa1.510164","name":"Available Hand Sanitizer Dispenser 1","group":"8b5cde76.edd58","order":3,"width":"6","height":"6","gtype":"wave","title":"Available Hand Sanitizer","label":"ml","format":"{{msg.payload[0].available}}","min":0,"max":"3000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"500","seg2":"1500","x":760,"y":940,"wires":[]},{"id":"af19c8b9.373f08","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":820,"wires":[]},{"id":"2385f349.ef9804","type":"inject","z":"5a245aa1.510164","name":"set level 1100","props":[{"p":"payload[0].available","v":"1100","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":320,"y":1020,"wires":[["ebc37340.ddfd9"]]},{"id":"1da1c840.e6bd6","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[{\"available\":0}]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":860,"wires":[["af19c8b9.373f08","ebc37340.ddfd9"]]},{"id":"90121f6c.ad8ee","type":"catch","z":"5a245aa1.510164","name":"","scope":["ebc37340.ddfd9"],"uncaught":false,"x":240,"y":860,"wires":[["1da1c840.e6bd6"]]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
But in long term may be worth rethinking the flow set up.