iOS icon indicating copy to clipboard operation
iOS copied to clipboard

imac_active binary_sensor remains on after shutdown

Open PierreScerri opened this issue 3 years ago • 1 comments

Device model, version and app version

Model Name: iMac (24" Early 2009) macOS Version: 10.15.3 App Version: 2021.6 (2021.158) Safari Version: Version 13.0.5 (15608.5.11) but using Brave (Version 1.25.70 Chromium: 91.0.4472.77 (Official Build) (x86_64))

Home Assistant Core Version

core-2021.6.3

**Describe the bug**

binary_sensor.pierres_imac_active remains active when iMac is shutdown.

To Reproduce

Shutdown the iMac

Expected behavior

binary_sensor.pierres_imac_active should switch to 'off' when iMac is shutdown.

Screenshots

Screenshot taken on iPhone after iMac is shutdown. PNG image

Additional context

PierreScerri avatar Jun 12 '21 09:06 PierreScerri

Issue still present

PierreScerri avatar Nov 24 '21 16:11 PierreScerri

I came here to report this issue but found this existing one instead.

I have a Mac mini M1 on macOS 13 Ventura and also a laptop on 12.3 and they both exhibit the same behaviour. HA is 2022.9.7 right now.

I was really hoping to use this sensor in a setup where a PIR switches lights off after a period of inactivity with the mac's active sensor overriding this behaviour in the event I'm sitting at my desk coding (not moving enough to keep the PIR active). I'll see if I can come up with a workaround for my use case but it would be far better if the Mac could switch the sensor on shut down, otherwise I struggle to see much of a reliable use for it.

Guddler avatar Nov 03 '22 13:11 Guddler

This sensor should go to "off" if the app is running before the shutdown and is quit by the system as a result. Can you describe the situation where it stays on?

zacwest avatar Nov 03 '22 15:11 zacwest

The sensor stays on with the app running when the system (iMac) is shutdown.

PierreScerri avatar Nov 03 '22 15:11 PierreScerri

This sensor should go to "off" if the app is running before the shutdown and is quit by the system as a result. Can you describe the situation where it stays on?

As Pierre says, there's not much to describe really! Shut your Mac down from the menu and the sensor doesn't change state, it continues to report active = true. Intel or M1 if that makes any difference.

Just to clarify, application is running at the time. Now, that's not to say that it's still running by the time the actual shutdown occurs, but I would assume it should be changing in the OS notify shutdown event hook, whatever that is called? So that should be fine. I haven't had a chance to properly look into the code yet.

Guddler avatar Nov 03 '22 16:11 Guddler

@Guddler this happens also with an iMac 24" (Catalina) and an iMac 27" (Big Sur). I don't think that it is the hardware causing the issue.

PierreScerri avatar Nov 03 '22 19:11 PierreScerri

@PierreScerri yes, I realise this is unlikely tied to a hardware issue - was just reporting that it happens on two different software architectures.

@zacwest After a little more testing this issue seems to be similar to other issues related to whether the application is set to run solely in the menu bar or also in the dock. If the app is set to run in the dock then the active state turns to off / false as you would expect on shut down. If you have the preference to only run in the menu bar then the change in state is not recorded.

I'm not familiar with the codebase at all but I'll do some digging over the weekend if I get time.

Guddler avatar Nov 03 '22 20:11 Guddler