Show that a service is running on a template card

I have a dashboard that I use to manage some entities that I am rate limited on, so HA only polls a few times per day. I have a card with a tap action to manually refresh via an exposed service. The service is pretty slow, and I’d like to add some kind of indication to the tile that the service call is in progress.

I can’t find any data that might help, though. I’m guessing that HA doesn’t maintain any sort of “in progress” state for service calls, because that would be very complex in parallel cases, but I was expecting to find some sort of “last started at” timestamp, which I could compare to a “last updated” entity and derive in-progress state. Am I just missing it? Or has anyone else come up with a solution to this problem?

Hi there!

It will be much easier, if you would give some more and preferrably detailed information.

Please give us something to work on. :slight_smile:

if the service is a script, the script’s entity will have a state ‘on’ when running that you can easily show. If it’s not a script, you can wrap it in a script if the service call is synchronous…

@paddy0174 I’m not sure what else I can provide, I’ll try to rephrase and summarize

I have a service call that updates a bunch of entities, and is slow. It is manually initiated via a tap action. My goal is to have some sort of visual feedback that the tap action has occurred on the card.

The core of my question is, is there any to tell (in the context of a card template) what a service call generated by a tap action is doing?

I was expecting to be able to use templating to render the card differently based on whether or not the service was running - something like the on state @armedad mentioned, but for services rather than for scripts. I can certainly wrap the service in a script, but that doesn’t scale particularly well as a pattern, or feel particularly elegant.

I was hoping for some more details, like what service-call, where does it come from (an integration or HA or…), why is the call slow and such things. In a nutshell, I was looking for an example with code, where we can discuss things on that example. :slight_smile:

Maybe there is something we can change on the card, or a “simple” template sensor could do the trick or… That’s why I was asking for more details. :laughing:

It’s hard to tell, the more information we get, the more directed the help can be. You know what I mean.

In a more general approach, I think it’s depending on how hard you’d like to “block” the button. If it’s only the button you want to lock, you could work with things like a timer up to just locking the card for another click.

The service is provided by an integration- does each service define properties that are exposed? I assumed that the service-running framework within HA would decorate with metadata but maybe not.

The call is non-local and interfaces with a slow system. My intent is not necessarily to block or debounce the button- the visual indication is more important. I’m not as interested in something that’s timer-based, though- I want something that is actually detecting the state of the service (running or not), not inferring it.

The card is not particularly interesting currently - it’s just an entity card with a tap action. Once I know what’s available in terms of information, I’ll decide the approach from there (templating or whatever).