Howto publish stateless button on Homekit

Hi,
I have this stateless button on lovelace using this defined switch in configuration.yaml:

switch:
  - platform: wake_on_lan
    mac: "a4:30:7a:4a:e2:d5"
    name: TV_WOL
    host: 192.168.4.54

I use it to wake up TV when it’s POWERED OFF.

but when I go to publish it on Homekit using this configuration in configuration.yaml:

homekit:
  - filter:
     include_entities:
       - switch.tv_wol

But now In Apple Home app I see a classic switch ON/OFF: the problem is when I switch it to ON, it remain s in ON position and send always wake-up packages to my TV…

How I can have stateless button in Aple home app?

1 Like

Create a script that toggles the switch on then off.

Include the script in Homekit instead of the switch.

thanks.

you are sayng to create on Apple device an automation or shortcuts that switch OFF button every time it see switched ON?

it’s not possible to do that directly on HA?

No I’m saying create a script in home assistant.

Then include that in your Homekit config, instead of the switch.

actual switch.tv_wol already is stateless: every time I switch on toggle, it return itself on OFF state in HA…but it don’t happen also in Apple Home app…

state of switches on Apple Home aren’t automatically synced with HA?

I hear you, and that sounds odd. The states should be synced, as long the state changes are emitted.

I don’t have such buttons like you, but I do have some scripts that emulate IR remote control button presses — scripts like Tom suggested. Those work fine in my case.

What you can do to test this, is to make an input boolean, wrap it in a script to turn it on, wait, and turn it off. Check that this then works in HomeKit by exposing the script to it. If that works, there must be another issue.

1 Like

Figured I’d chime in, in case it helps anyone else. But I wanted to have my Harmony Hub send a command to my air purifier as a stateless or toggle button in Homekit as well. I was able to achieve this by creating a ‘repeat’ script with a count of 1. So it automatically turns off or reverts after completing the action. Below is the yaml copied from the integration GUI:

repeat:
  count: '01'
  sequence:
    - service: remote.send_command
      data:
        device: '66843327'
        command: Auto
      target:
        entity_id: remote.bedroom_hub
2 Likes