I want a UI button to trigger a door unlock. This happens by executing a curl command.
I can already make it work in two ways:
1) a big button card:
It uses a “Call service” action that I defined previously. It works fine.
But I don’t want the big card with the single button, I want it in a group with other devices so, I tried something else that also works with
2) a switch entity:
The definition for this one is:
type: entities
entities:
- entity: switch.trinco
name: Abrir Porta
icon: mdi:door-closed-lock
title: Devices control
show_header_toggle: false
and the switch definition is done in configuration.yaml
:
switch:
- platform: command_line
switches:
trinco:
command_on: 'curl --insecure --digest --user "myuser:notreallymypassword" "https://10.0.0.121/api/switch/ctrl?switch=1&action=trigger" '
This one, although I find the configuration convoluted, is closer to what I need. But this doesn’t have a state, so I don’t need (and don’t like) the UI with two things to press, and some state information showing that is wrong. I want a button in there.
But I can’t get it to work, for the life of me, after hours running around in circles looking at woefully incomplete documentation.
3) A button helper
It’s not working! This is what I am looking for help with!
I tried adding this to configuration.yaml
shell_command:
trincar: 'curl --insecure --digest --user "geral:unidade" "https://10.0.0.121/api/switch/ctrl?switch=1&action=trigger" '
And then this in the card configuration:
type: entities
entities:
- entity: switch.trinco
name: Abrir Porta
icon: mdi:door-closed-lock
- entity: input_button.porta
name: Abrir porta V2
tap_action:
action: call_service
service: shell_command.trincar
title: Devices control
show_header_toggle: false
So, visually, V2 looks right:
But it doesn’t call the service.
If there’s another more direct way of achieving this, I’d love to hear about it. I just want a button entity that runs a shell command when you tap it… Thanks!