Change button color when pc is on (wake on lan)

Hi everyone,

I need a little help with wake on LAN.

I created a button to turn on my PC using wake on LAN, and it’s working fine.

I also created an automation to make the button turn yellow for 1 second when the PC turns on, and then return to its original color. However, I want to change this automation so that the color stays yellow as long as the PC is on, and then returns to its original color when the PC is turned off.

Does anyone have any ideas how I can do this?

Here is the code for the button:

show_name: true
show_icon: true
type: button
tap_action:
  action: toggle
entity: switch.lubas_pc
name: Lubas PC

Automation:

alias: botao-alt-est-lubaspc
description: Automation to make lubas-pc button change state for 1 s
trigger:
  - platform: state
    entity_id: switch.lubas_pc
    from: "off"
    to: "on"
    for: "00:00:01"
action:
  - service: switch.turn_off
    target:
      area_id: quarto
      entity_id: switch.lubas_pc
    data: {}