I am sorry, this is way beyond my skillset. but I can try some no-code solution.
if you really want a ui-template solution, please persist here, and some one will definitely pitch in.
[{"id":"708559a77743b59a","type":"ui_template","z":"5b623fd31ca86a42","group":"5dba1b1e2351399b","name":"","order":2,"width":"18","height":"9","format":"<body>\n\n <p>\n <a href=\"/a\" target=\"_blank\">\n <img border=\"0\" alt=\"Close\" src={{msg.payload}} width=\"400\" height=\"150\">\n </a>\n </p>\n ","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":840,"y":150,"wires":[[]]},{"id":"2b0f78a849b9af16","type":"ui_button","z":"5b623fd31ca86a42","name":"","group":"5dba1b1e2351399b","order":1,"width":"4","height":"2","passthru":false,"label":"{{label}}","tooltip":"","color":"","bgcolor":"{{bc}}","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":300,"y":150,"wires":[["564360172daf21db"]]},{"id":"564360172daf21db","type":"toggle","z":"5b623fd31ca86a42","name":"","onOffTopic":"","onValue":"open","onType":"str","offValue":"close","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"ifChanged","x":390,"y":150,"wires":[["931f00822e377529"]],"l":false},{"id":"c104ef27ac57ee07","type":"change","z":"5b623fd31ca86a42","name":"CLOSE","rules":[{"t":"set","p":"payload","pt":"msg","to":"/test/gate_close.gif","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"bc","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"label","pt":"msg","to":"closing....","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":125,"wires":[["708559a77743b59a","2ed345cc6c358675"]]},{"id":"22116413ca5c4e48","type":"change","z":"5b623fd31ca86a42","name":"OPEN","rules":[{"t":"set","p":"payload","pt":"msg","to":"/test/gate_open.gif","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"open","tot":"str"},{"t":"set","p":"bc","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"label","pt":"msg","to":"opening...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":175,"wires":[["708559a77743b59a","23a2dae7ea2109ba"]]},{"id":"931f00822e377529","type":"switch","z":"5b623fd31ca86a42","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"open","vt":"str"},{"t":"eq","v":"close","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":150,"wires":[["c104ef27ac57ee07"],["22116413ca5c4e48"]]},{"id":"e3755fbf3ac6e5fa","type":"link out","z":"5b623fd31ca86a42","name":"link out 303","mode":"link","links":["1232dc5aa44e144b"],"x":1010,"y":150,"wires":[]},{"id":"1232dc5aa44e144b","type":"link in","z":"5b623fd31ca86a42","name":"link in 317","links":["e3755fbf3ac6e5fa"],"x":185,"y":150,"wires":[["2b0f78a849b9af16"]]},{"id":"23a2dae7ea2109ba","type":"trigger","z":"5b623fd31ca86a42","name":"","op1":"","op2":"grey","op1type":"pay","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":840,"y":225,"wires":[["e3755fbf3ac6e5fa"],["9dcdf75583f39b6b"]]},{"id":"9dcdf75583f39b6b","type":"change","z":"5b623fd31ca86a42","name":"GREY","rules":[{"t":"set","p":"bc","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"label","pt":"msg","to":"PUSH TO CLOSE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1025,"y":225,"wires":[["e3755fbf3ac6e5fa"]]},{"id":"2cc17fce0745c18a","type":"change","z":"5b623fd31ca86a42","name":"GREY","rules":[{"t":"set","p":"bc","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"label","pt":"msg","to":"PUSH TO OPEN","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1025,"y":100,"wires":[["e3755fbf3ac6e5fa"]]},{"id":"2ed345cc6c358675","type":"trigger","z":"5b623fd31ca86a42","name":"","op1":"","op2":"grey","op1type":"pay","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":835,"y":75,"wires":[["e3755fbf3ac6e5fa"],["2cc17fce0745c18a"]]},{"id":"5dba1b1e2351399b","type":"ui_group","name":"Group 2","tab":"fb98fdb9.b193a","order":2,"disp":false,"width":"18","collapse":false,"className":""},{"id":"fb98fdb9.b193a","type":"ui_tab","name":"Home","icon":"dashboard","order":8}]