Send MQTT topic value to KNX switch to use Apple HomeKey

Hi,

I have successfully set up an ESP32 based Apple Homekey, which sends messages via MQTT. The messages do arrive in Home Assistant and I now want to trigger a KNX switch if the payload homekey:true is received. These messages will only be sent if an authenticated phone is presented to the NFC reader.

The incoming message looks as follows:

Message 1 received on homekey/auth at 9:18 PM:
{"endpointId":"0EF5B8274512","homekey":true,"issuerId":"2F39C4D29D6B15A2"}
QoS: 0 - Retain: false

I have a MQTT sensor configured like this:

mqtt:
  sensor:
    - state_topic: "homekey/auth"
      qos: 0
      name: "Homekey Nebeneingang"
      icon: mdi:lock

And this is the KNX switch:

knx:
  switch:
  ## Nebeneingang
    - name: "Nebeneingang öffnen"
      address: "5/0/12"
      state_address: "5/0/13"

How can I send “on” to the switch if a respective MQTT message is received?

Thank you!!
Klayman

Answer to self: This can be done with automations. For the above example I added the following trigger:

platform: mqtt
topic: homekey/auth
payload: true
value_template: "{{ value_json.homekey }}"

It might make sense to add the issuerID as an additional trigger. The action is then defined as follows:

service: switch.turn_on
metadata: {}
data: {}
target:
  entity_id: switch.nebeneingang_offnen

Here I still need to find out how to change from a switch to a boolean, so that I can send just a logical 1 to a certain KNX group address. Also not sure what happens if an already turned on switch is turned on again. But so far it works and we can open our door with the iPhone :smiley:

Best,
Klayman

Use a KNX button entity or the knx.send service.

For a KNX switch entity: Nothing.