Custom:button-card problem

Hello all,

i’m trying to create a card to control my ceiling fans.
In Developer Tools/Services these commands work fine, when i call the service and turns on/off the light on the ceiling fan.

service: remote.send_command
data:
  device: remote.ur1_livingroom_remote
  command: Light
target:
  device_id: a3597e1bec810e5dd6f1a33b49ab1cbc

when i’m trying to implement them in a custom:button-card buttom, they fail with a message:
Screenshot 2022-02-15 at 03.30.50

type: custom:button-card
color_type: card
color: orange
icon: mdi:ceiling-fan-light
name: On/Off
size: 45%
styles: null
card:
  - height: 70px
    script: null
tap_action:
  action: call-service
  service: remote.send_command
  data:
    device: remote.ur1_livingroom_remote
    command: Light
  target:
    device_id: a3597e1bec810e5dd6f1a33b49ab1cbc

can anyone help me?

Try using the entity id instead of the device id.

tap_action:
  action: call-service
  service: remote.send_command
  data:
    command: Light # this is probably 'light' not 'Light'
  target:
    device: remote.ur1_livingroom_remote

i used exactly your code, the same

tap_action:
  action: call-service
  service: remote.send_command
  data:
    command: Light
  target:
    device: remote.ur1_livingroom_remote

the command is Light, i recorded them…

Yeah you’re right I just checked one of mine (in a script) and it does support upper case:

  - service: remote.send_command
    target:
      entity_id: remote.lounge_tv
    data:
      command: 'ON'

I stuffed up my code, try this:

tap_action:
  action: call-service
  service: remote.send_command
  service_data:    #### <----- I changed this
    command: Light
  target:
    entity_id: remote.ur1_livingroom_remote #### <----- I changed this

Screenshot 2022-02-15 at 04.15.32

What about this:

tap_action:
  action: call-service
  service: remote.send_command
  service_data:    #### <----- I changed this
    command: Light
    entity_id: remote.ur1_livingroom_remote #### <----- I changed this
2022-02-15 04:31:27 ERROR (MainThread) [homeassistant.components.broadlink.remote] Failed to call remote.send_command: You need to specify a device
2022-02-15 04:31:27 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140469649177040] You need to specify a device
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 190, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 668, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 705, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/broadlink/remote.py", line 221, in async_send_command
    code_list = self._extract_codes(commands, subdevice)
  File "/usr/src/homeassistant/homeassistant/components/broadlink/remote.py", line 141, in _extract_codes
    raise ValueError("You need to specify a device")
ValueError: You need to specify a device

I just tried this and it worked:

type: button
tap_action:
  action: call-service
  service: remote.send_command
  service_data:
    command: 'ON'
  target:
    entity_id: remote.lounge_tv
entity: remote.lounge_tv

So translating that across to your device:

type: button
tap_action:
  action: call-service
  service: remote.send_command
  service_data:
    command: 'Light'
  target:
    entity_id: remote.ur1_livingroom_remote
entity: remote.ur1_livingroom_remote

this one works as a button…

type: button
tap_action:
  action: call-service
  service: remote.send_command
  service_data:
    command: Light
    device: remote.ur1_livingroom_remote
  target:
    entity_id: remote.ur1_livingroom_remote
entity: remote.ur1_livingroom_remote

well, this works only as button, not as custom:button-card with all fancy stuff… :frowning:

      - type: button
        name: Light On/Off
        icon: mdi:ceiling-fan-light
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: Light
            device: remote.ur1_livingroom_remote
          target:
            entity_id: remote.ur1_livingroom_remote
        show_state: true

Move the entity_id to service data and delete the target line

Thank you all, very very much !!!

this worked :slight_smile:

type: custom:button-card
color_type: card
color: orange
icon: mdi:ceiling-fan-light
name: Light
size: 45%
styles: null
card:
  - height: 70px
tap_action:
  action: call-service
  service: remote.send_command
  service_data:
    command: Light
    device: remote.ur1_livingroom_remote
    entity_id: remote.ur1_livingroom_remote

this is the result…

Screenshot 2022-02-15 at 06.06.29

Sorry, this whole time I was looking at the button card, not the custom button card.

1 Like