More button colour control - a whole new saga

Well, I'm not sure Dashboard is the right thing, but.....

I've recently posted a flow with buttons that change colour as you press them with indicator LEDs to show what is happening and if there is a difference.

That works.

Next/new problem/project:
(I'll do a walk through as I am very much at the start of how to get the signals at this stage and so don't really have a flow to show for it.)
Machine 1:
Button to invoke a command (CLI/SHELL) on a remote machine.
Button changes from LIME to BLACK when pressed.
The command is sent.
An acknowledgement is received. (Maybe change button to GREY colour.)
The return code is received.
If all good, the button returns to LIME.
If a warning, the button turns YELLOW.
If a failure, the button turns RED.

The idea is simple enough, but there are ..... 24 buttons (for now).

I get that is a lot of ground work and it all can't be done via magic.

But with my programming skills that is a lot of work.

I'm wanting to ask/learn/know if there is a way I can (rather than use the supplied buttons) build my own buttons like:

[{"id":"b04649a2.b78018","type":"ui_template","z":"e0bd2889.28018","group":"42382e93.83c508","name":"off","order":8,"width":"1","height":"1","format":"\n<md-button class=\"vibrate filled touched smallfont rounded\" style=\"background-color:#8e44ad\" ng-click=\"send({payload: 'Hello World'})\"> \n    Off\n</md-button> \n\n","storeOutMessages":true,"fwdInMessages":true,"x":210,"y":340,"wires":[[]]},{"id":"42382e93.83c508","type":"ui_group","z":"","name":"Default","tab":"d109c4c9.944c98","disp":true,"width":"6"},{"id":"d109c4c9.944c98","type":"ui_tab","z":"","name":"Button examples","icon":"dashboard","order":3}]

and make it a bit more.... "self contained"?

I get that there will have to be a LOT of filtering for all the devices and their possible states.
But if that could be done on the button's code I can just get the return messages and feed it to all the buttons and they sort it out internally. Rather than doing it externally with SWITCH nodes, etc.

I'm just asking and getting it out there as someone (may) have a similar thing going and we could (again: maybe) help each other.

This is the sort of return message I have now:

{"topic":"COMMAND_REPLY/TimePi","payload":"{\"code\":0}","qos":2,"retain":false,"_msgid":"45d117c1.288548"}

That is a good reply.
I think code:127 is a failure and there are codes 1 & 2. I'm still looking into that part of it.

Thanks in advance.