Hi, I’m new to HA but have experience with KNX and computer programming. I had no problem setting up light switches and dimmers but when it comes to buttons I got absolutely stuck. What I want is to send a 1 (one bit value) when a button is pressed and 0 when the button is released?
I’m a completely new to YAML and would really appreciate if someone could give me some example of how to achieve this.
Thank you!
Hi !
The default cards don’t support “release” actions. Maybe you can find custom cards that do.
Ok, would it be possible to achieve a “pulse” by sending 1 at key press and a second later send a 0?
Yes. That’s what scripts are for. It can probably also be done with a template button. Use knx.send
and delay
for that.
Ok, thanks a lot! Could you please give me a brief example of a script and how to call the script from a button press?
Thank you!
Maybe something like this, but how do I run the script from a button press?
script:
automation:
- name: auto
- knx.send:
address: "1/0/0"
value: True
type: "5.010"
delay: 1
- knx.send:
address: "1/0/0"
value: False
type: "5.010"
Well, replace value
with payload
and maybe don’t use boolean as percent-payload. See https://www.home-assistant.io/integrations/knx/#send
I’m not sure how to call it. Last time I checked, it was just displayed like a button in the default dashboard, but that’s long time ago
Otherwise use a template button invoking the script or just calling this sequence.
Ok, I realise now you can run the script by itself from the dashboard. I tried the following but nothing showed up on the KNX bus when I run it from the script builder dialog!?
sequence:
- knx.send:
address: 1/0/0
payload: 1
payload_length: 1
delay: 1
- knx.send:
address: 1/0/0
payload: 0
payload_length: 1
Please have a look at the documentation. https://www.home-assistant.io/docs/scripts/#call-a-service
and https://www.home-assistant.io/integrations/script/
You are missing service: knx.send
and data:
Thank you for your reply!
Slowly getting there…
Tried this but nothing happens on the KNX bus?
sequence:
- service: knx.send
data:
address: 1/0/0
payload: 1
payload_length: 1
delay: 1
- service: knx.send
data:
address: 1/0/0
payload: 0
payload_length: 1
If you had a look at the logs, you’d probably see where the issue is.
delay
can not be part of the knx.send
service call, but is a separate item of the sequence.
Nothing is showing up in the logs!? Not even when I reduced the script to this:
sequence:
- service: knx.send
data:
address: 1/0/0
payload: 1
this Script, done by the UI builder, yields the following yaml that works flawlessly on my system
alias: Test
sequence:
- service: knx.send
data:
payload: 1
address: 0/4/1
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: knx.send
data:
payload: 0
address: 0/4/1
mode: single
You are firing an event, not calling a service. You picked the wrong action type.
Thank you so much!
Now I’m beginning to understand how things should be done. Now it’s working fine for me.