Switch turning itself back on after command_off

Hi HA Community

I have a switch (below) using command_on and command_off. When I click the button to turn it off (command_off), it shuts down properly but then immediately turns back on (command_on).

All commands below (on, off, state) all work below.

I tried changing the Mac address for command_on to an invalid Mac, and it no longer turns on. So it appears HA is triggering the command_off then immediately firing the command_on.

  - platform: command_line
    switches:
      desktoppc:
        friendly_name: Desktop PC
        command_on: /usr/bin/wakeonlan XX:XX:XX:XX:XX:XX
        command_off: /usr/bin/curl --max-time 3 -u user:pass -k http://Desktop-PC.local.lan:8000/?action=System.Shutdown
        command_state: /usr/bin/curl --max-time 3 -u user:pass -k http://Desktop-PC.local.lan:8000 >/dev/null 2>&1

I also noticed that after changing command_on to an incorrect Mac address, the switch first changes to this state for about 3-5seconds. I’m guessing this is a pending off type state.

Then it changes back to on (device isn’t on). I think this might be because command_state returns true while thge PC is still shutting down. Then it stays ‘on’ for about 10 seconds.

Then it finally switches back to the weird pending off state? It then stays in this state.

When I shut the PC down normally (outside of HA), it doesn’t show the pending off icon. It’s just off. Any tips HA community?

Bump

Any tips please?