Service execution (shell command) from a button in an integration

Hello, i have a button who fire a shell script who send via curl some PTZ commands to my cam, record a 30 sec. video, then set the camera to default preset.
I use custom gallery card to watch the video from lovelace, and it has a button to manually reload the media from disk.
So actually i have to press the “script button”, wait for 1 min, then manually reload the card. Is there some trick i can do?

…i have seen into the gallery-card.js there is the “reload button link” of the component… can i add an action there? How to add it?

${this.currentResourceIndex == undefined || !(this.config.show_reload ?? false) ?
            html`` : html`<ha-progress-button class="btn-reload" @click="${ev => this._loadResources(this._hass)}">Reload</ha-progress-button>` }
          <div class="resource-viewer" @touchstart="${ev => this._handleTouchStart(ev)}" @touchmove="${ev => this._handleTouchMove(ev)}">

So i should write…

@click="${ev => this.LAUNCHSCRIPT & this._loadResources(this._hass)}


I’m pretty sure it can be done…

i’ve found this statement:
            {"entity_id": CAMERA_ENTITY_ID, "filename": self.current_garage_pic_file},

and this one:

‘domain’: domain_string,
‘service’: service_string,
‘service_data’: service_data_string,
‘service_call_id’: call_id})

…my service is “shell_command.traffic_cam”, withouth options or output variables…
Tried many time into the developer inspect chrome window, but give always me error
Any hint?

… fortunely chatGPT helped a lot!! :slight_smile:

to call a service:
@click="${ev => this._hass.callService('shell_command', 'traffic_cam', {})}

To refresh the card:

to call the service, wait 50sec and then refresh:

@click="${ev => { this._hass.callService('shell_command', 'traffic_cam', {}); setTimeout(() => { this._loadResources(this._hass); }, 50000);}}"

note that in my plugin, x.hass.y is x._hass.y (declared at the start)

…Solved but… now i need a counter to wait :slight_smile: