Call-service not working: connection lost

Hi

I have a button which calls a service:

show_name: false
show_icon: true
type: custom:button-card
tap_action:
  action: call-service
  service: surepetcare.set_pet_location
  data:
    pet_name: Mosi
    location: Inside
entity: binary_sensor.mosi
show_state: false
icon: mdi:tree
color: yellow

When I click, I get an error message (in Italian)

Invocazione del servizio surepetcare/set_pet_location non riuscita. connection lost

But when I go to the developer tools and test the service it works

service: surepetcare.set_pet_location
data:
  pet_name: Mosi
  location: Inside

Do you have any idea on what could be wrong?

Looks like it lost the connection. What happens if you put the service in a script and call the script as the tap action service?

Thanks for the quick reply.

Same as before: the script works but calling it as a tap action leads to the connection lost error:

square: false
type: grid
columns: 1
cards:
  - type: conditional
    conditions:
      - entity: binary_sensor.mosi
        state: 'off'
    card:
      show_name: false
      show_icon: true
      type: custom:button-card
      tap_action:
        action: call-service
        service: script.mosi_in_casa
      entity: binary_sensor.mosi
      show_state: false
      icon: mdi:tree
      color: yellow
  - type: conditional
    conditions:
      - entity: binary_sensor.mosi
        state: 'on'
    card:
      show_name: false
      show_icon: true
      type: custom:button-card
      icon: mdi:home
      color: green
      tap_action:
        action: call-service
        service: script.mosi_esterno
      entity: binary_sensor.mosi
      show_state: false

and both scripts:

alias: Mosi all'esterno
sequence:
  - service: surepetcare.set_pet_location
    data:
      pet_name: Mosi
      location: Outside
mode: single
icon: mdi:cat

and

alias: Mosi in casa
sequence:
  - service: surepetcare.set_pet_location
    data:
      pet_name: Mosi
      location: Inside
mode: single
icon: mdi:cat

Even simplifying the button, yields to the same connection lost error:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: script.mosi_in_casa
entity: binary_sensor.mosi

Not a single relevant entry in the log file (even with debugging enabled)

So I had a similar issue and after I figured out what was the fault.
It is nothing to do with timeout of whatsoever. The configuration was not correct. In your case you can try “service_data” instead of “data”.

In my config it looks like this:

- type: custom:button-card
  icon: mdi:stop-circle-outline
  tap_action:
    action: call-service
    service: cover.stop_cover
    service_data:
      entity_id: cover.dining_room_shutter
2 Likes

Dear Harrer,

thanks but I don’t have any data to submit. The service has no parameters.

Matteo

I have the same problem. Very strange. Other scripts work fine and can be called, but one (which is a copy of a working one) doesn’t want to run and keeps saying “connection lost”

Oh, interstingly the developer tools show me, that my entity is called

image

instead of what the script editor tells me:

image

Trying with the entity ID above it works

I have the same issue! Push!

  - type: call-service
    name: Open Valve for Duration
    action_name: Open
    service: script.open_valve_for_duration

the script is callable from scripts but the button gives me:

Failed to call service script/open_valve_for_duration. connection lost

But i then realized that in entities, the id is

but in the dev options it says:
image

and calling the latter works. This must be a bug.