H
HASS.Agent4w ago
eastern-cyan

MonitorPowerState status not changing on MQTT after waking up

Hello! I'm new to HASS and I've been configuring it using the wiki. The sensor that I want to use is MonitorPowerState to turn on my Speakers when the monitor wakes up. But it was working erratically (mostly never, but sometimes it does work) and I¡ve been trying to figure out why. So I installed MQTT Explorer an realised this: When the computer sleeps (and monitor goes off) the state changes to PowerOff and MQTT received PowerOff....but when I wake up the PC, the state changes to PowerOn on hass.agent but on MQTT Explorer it does not change (and therefore my automation does not trigger) could someone help me figure out the reason? thank you
No description
No description
No description
No description
5 Replies
eastern-cyan
eastern-cyanOP4w ago
Update: I've been able to see that this happens only when the computers wakes up from suspension (which is my main use case) If the screen turns on but the pc was not suspended, it works properly
Ellie
Ellie3w ago
idk how to fix this, but to get around it, you can use LastSystemStateChange and trigger when it changes to being not unavailable or Suspend. That one will always show either resume or session unlock when the pc wakes and be unavailable or Suspend when its asleep here's a template i use for a PCState Switch Entity
pc_state:
friendly_name: PC
value_template: "{{false if states('sensor.pc_lastsystemstatechange') in ['unavailable', 'Suspend'] else true}}"
turn_on:
service: wake_on_lan.send_magic_packet
data:
mac:
broadcast_port: 9
turn_off:
service: button.press
target:
entity_id: button.pc_sleep
icon_template: mdi:desktop-classic
pc_state:
friendly_name: PC
value_template: "{{false if states('sensor.pc_lastsystemstatechange') in ['unavailable', 'Suspend'] else true}}"
turn_on:
service: wake_on_lan.send_magic_packet
data:
mac:
broadcast_port: 9
turn_off:
service: button.press
target:
entity_id: button.pc_sleep
icon_template: mdi:desktop-classic
DrR0x
DrR0x3w ago
@Amadeo i feel like we talked about this a while back, should maybe be a docs comment?
Amadeo
Amadeo3w ago
I actually though about it a day or two ago, some 2 sections or so about "m0e3rn sleep" and the basics - the question is how do we create one that covers all cases 😄
optimistic-gold
optimistic-gold2w ago
I was trying to do the exact same, but I found giving my PC a static IP and using the ping integration to determine if my PC was on or not worked out better. I will start my own thread with more details.

Did you find this page helpful?