custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.93k stars 233 forks source link

Failed to call switch/turn_on service. must contain at least one of entity_id, device_id, area_id. #709

Closed jay-kub closed 1 year ago

jay-kub commented 1 year ago

Checklist

Describe the bug Receiving the error below even when an entity_id is present

_Failed to call switch/turn_on service. must contain at least one of entity_id, device_id, areaid.

Version of the card Version: 3.5.0

To Reproduce This is the configuration I used:

                            - type: custom:button-card
                              entity_id: light.light_entry_corner_hue
                              name: 'Off'
                              show_name: true
                              show_icon: false
                              tap_action:
                                action: call-service
                                service: light.turn_off
                                target:
                                  entity_id: >-
                                    light.light_entry_lamp
                                    light.light_entry
                                    light.kitchen

Screenshots If applicable, add screenshots to help explain your problem.

Expected behavior Lights to turn off

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

MikeGuest commented 1 year ago

Experiencing the same issue with this config below. Changing the type from custom:button-card to button makes the problem go away.

  - type: 'custom:button-card'
#  - type: 'button'
    theme: Github Dark Theme
    show_icon: false
    show_name: false
    show_state: yes
    entity: input_text.time
    styles:
      card:
        - font-size: 24px
        - font-weight: bold
    tap_action:
      action: call-service
      service: input_boolean.turn_on
      target:
        entity_id: input_boolean.desktop_screensaver 

Tried: Moving the 'target' section above the service within tap_action. Tried: Leaving an extra space at the bottom of the yaml file

image

MikeGuest commented 1 year ago

Possible solution:

The call appears to work if you use service_data: instead of target:

However, this differs from the implementation of the standard button card, so I'd suggest it should be considered as an improvement.

Mariusthvdb commented 1 year ago

dear people,

You should really just follow the docs of this custom button-card, and not try to use the syntax of an unrelated card, (even though it is core).

What you concluded just now has been standard procedure for a very long time, some years even probably

Thing is, all of these posts ping all subscribed users, and while it might seem a challenge for you, these are not considered 'issues'/'bugs' for which these repo posts are.

Check the green buttons wording.

If you are still somewhat unfamiliar with the card, please first check the appropriate topic in the community where we all are glad to help you out.

jay-kub commented 1 year ago

My apologies for not seeing that it should be "service_data:" as called out in the docs. I had copied this code from another user and haven't done a deep enough dive on the configuration options yet.

After updating it to service_data I am now getting an error stating:

Failed to call service light/turn_on connection lost"

Is this a common issue? I can't seem to find any similar issues reported.

Mariusthvdb commented 1 year ago

where in the docs did you find that syntax toggling more than 1 light? as said please go to community topic on this button-card and ask for help

RomRider commented 1 year ago

This syntax works in the latest beta now 😃