Create a switch that consumes an api but when trying to associate this switch with a Picture Elements Card, only the ON works, but when you touch it again the Light does not turn off (or execute the body_off command)
Switch:
switch:
- platform: rest
name: dormitorio
resource: http://192.168.1.117:3000/assistant
body_on: '{"command": "Encender Luz Dormitorio"}'
body_off: '{"command": "Apagar Luz Dormitorio"}'
headers:
Content-Type: application/json
light:
- platform: switch
name: Luz Dormitorio
entity_id: switch.dormitorio
Picture Elements Card
- entity: light.luzdormitorio
image: /local/lightoff.png
state_filter:
'off': /local/lightoff.png
'on': /local/lighton.png
state_image:
'on': /local/lighton.png
style:
left: 20%
padding: 10px
top: 92%
width: 7%
tap_action:
action: toggle
type: image