Need help with turn on and off my PC

Hello :slight_smile:

I have a configuration in openhab that is a button that turn my PC via WOL, and turn off my PC via a GET via http, (actually sent it to hibernate)

How can i do that in one switch?
Is there a way to know the state of the PC on that switch?
Or maybe doing like in openhab, with 2 diferent buttons?

Right now, i dont know how to do the GET thing

Thanks.

So i did this and works.
Now, how to put the state of the PC on the switch?

And still looking for a separate button config. Thanks

 switch:
   - platform: wake_on_lan
     mac: "xx:xx:xx:xx:xx:xx"
     name: pc
     host: 192.168.0.100
     turn_off:
       service: shell_command.turn_off_pc
 
 shell_command:
   turn_off_pc: "curl http://192.168.0.100:5001/secret/hibernate"

This is mine :

  - platform: template
    switches:
      desktop_destiny:
        value_template: "{{ is_state('binary_sensor.desktopdestiny', 'on') }}"
        turn_on:
          - service: wake_on_lan.send_magic_packet
            data:
              mac: 'd4:3d:7e:2e:89:53'
        turn_off:
          - service: mqtt.publish
            data:
              topic: iotlink/workgroup/desktop-destiny/commands/shutdown

This is a ping sensor :

is_state('binary_sensor.desktopdestiny'
  - platform: ping
    name: desktopdestiny
    host: 10.0.0.62
    count: 2

For shutdown I use iotlink, don’t know how to adapt it for a shell_command.

This worked for me for a while and all of a sudden stopped