Can the macOS companion app put my displays to sleep?

Using the Home Assistant Companion app on my macOS laptops (personal laptop and a work laptop), it’s been very handy to use it to trigger automations when the camera goes active to turn on some lighting in preparation for a video conference, etc.

What I’d like to have is some limited ways to control the macOS system from Home Assistant. The immediate “need” that I have is to be able to tell the laptop to put its displays to sleep. So, at the end of the workday, when I walk away from the work desk and laptop at home, I’d like to have the displays go dark/asleep - this will tell other software like the Slack client that I’m “away” as well as saving a few watts of power.

You can imagine other similar kinds of things that could be useful.

Looking that documentation, I see there’s a bunch of distinguished notification messages to perform various commands for Android, but I haven’t seem something that I could use to address my need to put the displays to sleep. (Today, I use a keyboard shortcut to bring up Alfred and then a quick shortcut an Alfred “system command” to put the displays to sleep.

2 Likes

I can’t help, but that’s an awesome idea.

I’ve discovered that I can put my macOS system display(s) to sleep as I wanted by running a shell command

pmset displaysleepnow

to cause this to happen. So I suspect I could build a script or something to listen to an MQTT topic, maybe expose a switch or button MQTT entity to that end.

It’d be great of the Home Assistant macOS application could do a similar thing for me…