Custom button-card multiple actions based on other button states

I’m trying to create a remote which changes tap_action and hold_action button functionality based on the harmony activity selected by the remote.

I’ve created the buttons for the harmony activities and these work fine, with color change etc, but I can’t seem to find a way to select multiple actions for the same button.

I’m using custom:button-card I can’t seem to be able to find a way to change the tap_action for a number button to change my kodi channel directly via kodi API when on an kodi harmony activity and interact with a predefined harmony devices remote when on another activity.

The service definition of a service to interact with kodi is different than the one to interact with armony commands so this adds to the complexity since I can’t just define templates for each action it seems. Templates only work for a single action for a single button.

I tried using states but these seem to be able to control only the button style and state.

State templates also don’t seem to work with tap_action as far as I can see from the documentation and every atempt I made fails to achieve what I want.

Any idea? Has anybody done the same with their remotes?

Thanks in advance.

You can use variables, so depending on the state the relevant variable is called or you can use custom fields and stack buttons on top of each other.

Thanks NovaG.

I tried using variables but because the service definition is different for the different actions
I’m struggling to see how I can work around that

I haven’t worked with stacked buttons and custom fields yet, it sounds like that might do it.
If you have a short example of how you would achieve this with stack buttons that would be much appreciated.
Custom fields also seem to be related to styles only as well, or can they be used for tap_actions as well for example?