Unfortunately I still have some difficulties to find my way in yaml with templates.
I have created some dummy switches to control my Ikea lamps via my KNX light switches. I syncronize these switches with the status of my ikea switches when they are turned on or off.
After starting the server these switches are unfortunately not syncron until they have been pressed once.
So I wanted to create an automation that would initialize the switches when starting the server. The script does not report an error but unfortunately the automation is also without function.
Can you show how you configure your switches? Do they get out of sync if you toggle the lights via Ikea app (or whatever they can be toggled with that is not knx and not HA)?
I think you could expose the entity_id to knx (https://www.home-assistant.io/integrations/knx#exposing-sensor-values-or-time-to-knx-bus) and use this GA as listening address on your switch. Exposures send on HA start. It may double-send the status then - to avoid this you can (if you have) omit the state_address of your switch as the exposure takes care of this.
This automation will switch the light if the physical KNX switch is pressed (which is only working if the KNX dummy switch and the light have the same state):
So far so good, but if i restart the HA server and the light is still turned ON the KNX switch will remain OFF.
Before i can switch off the light via the KNX switch i have to press ON on the KNX switch to mirror the state and after that i am able to control the light as usual.
Exposing the light to knx sounds like a good plan to reduce many automations
but as the light is not assigned to any KNX actors, i will not have a state_address on the KNX bus.
I will try that later today and post the result.
Whats the correct sensor type in HA to represent a switch 1.001 1bit?
I tried to expose it as a binary but switching the light On or Off from HA will not send any messages to the KNX bus.
The knx switch has an internal state (on or off) and on every press it sends the other one. Every time a value is received over the bus the state gets updated - this way every switch stays in sync.
I think the switch device only sends when it is used (the switch itself it toggled). The expose device should send on every update.
I’m afraid somehow that doesn’t want to actually work.
Do you have any idea why this code doesn’t work?
Then I would use it until I found a better solution.
I want to use a button on my universal interface (KNX) switch to communicate with an HA automation.
The button is not allocated with an actuator.
Do you have an idea how I can get that working?
Maybe you can provide some screenshots of the ETS configuration you used for that groupaddress?