Tsar
(Christian)
December 29, 2021, 12:58pm
1
Why do I get this pop-up instead of switching my aircon on/off ?
type: custom:button-card
name: gang
state:
- value: 'on'
color: red
spin: true
tap_action:
action: call-service
service: climate.turn_off
service_data: {}
target:
entity_id: climate.airco_gang
- value: 'off'
color: green
spin: false
tap_action:
action: call-service
service: climate.turn_on
service_data: {}
target:
entity_id: climate.airco_gang
entity: sensor.airco_gang_is_on_or_off
Because you’re not following the Readme. Tap_action doesn’t go under state, it goes directly under the card (like state, name, entity). Tap_action is not an option within state .
Follow the Readme on Github and copy/paste the examples and alter them to your own needs. In your case you should either use toggle as action (if climate supports that) or use a template like explained there.
Also, it’s easier to ask for help in a thread dedicated to this card that has already over 6000 replies, than creating your own. You can search withing that thread and most likely have answers to a lot of questions:
Button card
Lovelace Button card for your entities. -> github
[all]
Features
works with any toggleable entity
3 actions on tap toggle, more_info and service
state display (optional)
custom color for on and off state (optional)
custom state definition with customizable color (optional)
custom size (optional)
custom icon (optional)
custom css style (optional)
automatic color for light (optional)
custom default color for lights (when color cannot be determined) (optional)
2 color types
icon :…
Tsar
(Christian)
December 29, 2021, 5:28pm
3
Thank you for pointing me the way. I’m just starting with HA, so it’s a lot to accumulate and finding my way where to go for information & help.
I think I can’t use toggle as action, because I had to create a binary sensor to know the status of my aircon.
I think I almost there, but my Java is far away
type: custom:button-card
name: gang
state:
- value: 'on'
color: red
spin: true
- value: 'off'
color: green
spin: false
tap_action:
action: call-service
service: |
[[[
if states['binary_sensor.airco_gang_is_on'] == 'on'
return 'climate.turn_off';
else
return 'climate.turn_on';
]]]
service_data: {}
target:
entity_id: climate.airco_gang
entity: binary_sensor.airco_gang_is_on
1 Like
I ran into this too. For the tap_action I call a script in which I check the state and call the appropriate action. This way I do not have to mess with Java.
2 Likes
Tsar
(Christian)
April 15, 2022, 5:55pm
5
Did it that way too
tap_action:
action: call-service
service: script.airco_togglen
service_data:
entity_id: climate.airco_gang
target: {}
entity: binary_sensor.airco_gang_is_on
maybe too late, but i did it like this:
- type: custom:decluttering-card
template: button
variables:
- entity: binary_sensor.alfen_https_api_login_status
- name: Connectie
- icon: connection
- label:
- show_state: true
- margin-right: 40px
- lock: true
- tap_action:
action: call-service
service: button.press
data:
target:
entity_id: |
[[[
return (entity.state === 'on') ? 'button.alfen_https_api_logout' : 'button.alfen_https_api_login';
]]]
No need to use decluttering-card for one custom:button-card, it supports own templates.
Yeah, but I use declutter for all my cards