sleevezipper / hass-workstation-service

Provide useful sensors and services from your workstation to Home Assistant.
Apache License 2.0
613 stars 54 forks source link

On computer wake from sleep, SessionStateSensor remains Unknown #172

Open amaisano opened 2 years ago

amaisano commented 2 years ago

I have two Windows 10 machines in my office. Both exhibit this behavior.

After choosing "Sleep" from the Windows start menu, upon waking back up via a Wake On Lan command (wake on magic packet via LAN) or keyboard, HASS W doesn't report a change from the SessionStateSensor to Home Assistant.

Waking the machine puts me back into the lock screen, by the way, for security purposes.

The LastActivity sensor works (is picking up when I move my mouse), but the SessionStateSensor (InUse, Off, etc) is stuck on Unknown.

If I unlock my screen, then lock my screen again, SessionStateSensor goes to Locked. But I don't want to have to do that after waking up and unlocking the first time .

Here's the timeline

  1. Launch HASS Workstation Unknown -> InUse
  2. Click "Sleep" in Windows InUse -> Locked -> Off -> Unknown (happens over 1-2 minutes)
  3. Wake computer by tapping the keyboard or using a wake_on_lan command Unknown (no transition)
  4. Unlock and get back into Windows still Unknown (no transition, but LastActivity is working)
  5. Lock screen (Windows + L) Unknown -> Locked
  6. Unlock screen (enter password) Locked -> InUse

If it's stuck in Unknown and I edit the SessionStateSensor in the UI, (without actually changing anything) and click save, it bumps it to InUse in Home Assistant.

Any tips? It seems somewhat related to https://github.com/sleevezipper/hass-workstation-service/issues/58 and/or https://github.com/sleevezipper/hass-workstation-service/issues/46

cromelex commented 2 years ago

I have the exact same issue, exactly as described.

HeedfulCrayon commented 2 years ago

Related to #168 too

amaisano commented 2 years ago

FYI I am using this workaround.

  1. Create a HASS WS sensor for GPU or CPU temperature.
  2. Create a template binary_sensor in HA called "PC Power" and set it to this new HASS WS sensor:
value_template: "{{ is_number(states('sensor.bebop_gpu_temp')) }}"
  1. Profit. Apparently the GPU/CPU sensor always seems to work after sleep/wake, and is instantaneous. It's either a number, or it's unknown when the PC is off (not a number).