I want to create a button card with following function:
If I click on the button I want to check if a light is turned on and then send 1 to a group address on the knx bus. I’m a beginner and I don’t know how to do this.
I created a template but i doesn’t work:
It seems you are trying to do the same thing, regardless if the switch is turned ON or OFF. If so consider just using a button (a knx button just sends your payload on press - stateless).
The thing you apparently copied from the documentation is not the correct service notation, but just a documentation schema for services. See the examples or service documentation for the correct notation. Here is an example:
service: knx.send
data:
address: 1/1/0
payload: 1
Here you can try these things and even fill the yaml text-field with more-or-less usefull example data:
There is no type: switch. If you want to knx.send binary data (DPT1) just send a numeric payload of 0 or 1 without type.
Maybe I phrased something wrong. Actually, I don’t want a switch, just a button that I can press.
If I press it sends a value to the KNX bus (to a group address) based on the state of a switch… in this case 1
Can you give me a little example? I’m a beginner and if I can see an example it would help me very much to understand it better.
No, a Knx button entity always sends the same payload. Templates can’t be used there.
Is light.kuechenspots a Knx entity? Then you could maybe use its GA as state of an Knx Switch and the address you want to send to as address - not sure if this works, you’ll have to try.
Otherwise create a HA script. This will look like a button (or HA scene) in Lovelace and you can use services (knx.send) and templates there.
Or create a template button (documentation for this seems quite sparse unfortunately).