custom-cards / button-card

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

Problem Calling Input Select #802

Closed Boh1 closed 7 months ago

Boh1 commented 7 months ago

I'm having a problem where attempting to cycle through input_select options using a call_service action results in the following error:

Failed to call service input_select/select_next. must contain at least one of entity_id, device_id, area_id.

This is the complete code for this button:

  - type: 'custom:button-card'
    color_type: icon
    entity: input_select.desk_preset
    layout: icon_label

    label: >
      [[[
        return 'Desk Preset: ' + states['input_select.desk_preset'].state;
      ]]]

    tap_action:
      action: call-service
      service: input_select.select_next
      data:
        entity_id: input_select.desk_preset
        cycle: true

    show_name: false
    show_label: true

    styles:
      card:
        - height: 100px
    state:
      - value: 'Preset 1'
        styles:
          icon:
            - color: blue
      - value: 'Preset 2'
        styles:
          icon:
            - color: green

Making the same call via the Developer Tools Call Service interface works as expected.

Boh1 commented 7 months ago

EDIT -Resolved.

The issue was with the use of data(as shown multiple times in the README) versus using service-data.

I'm not sure why this nuance, but I have the code working now.

Just in case anyone trips across this in a search, I have posted a working code snippet below:

    tap_action:
      action: call-service
      service: input_select.select_next
      service_data:
        entity_id: input_select.desk_preset
        cycle: true