In my home setting, my computer (Mac running High Sierra) is sitting right next the TV. I've setup a automation with home-assistant that dims my room lights whenever the TV is running, but I also needed to sleep my computer screen for the automation to be complete so I've developed this little project.
It just exposes a very simple HTTP API so that I can remotely sleep and wake my computer display.
---
switch-apiSimple http server that triggers system commands on predefined URLs
- used in conjunction with https://home-assistant.io/components/switch.rest/
- http://pm2.keymetrics.io for automatic startup
Control macbook display (on macOS Sierra)
- GET /display : get current screen state (sleeping or not)
- POST /display body=ON|OFF : switch screeen state
- sleep display:
pmset displaysleepnow
- wake display:
caffeinate -u -t 1
- test state :
pmset -g powerstate IODisplayWrangler | tail -1 | cut -c29
result <4 are sleeping
1 project • 0 followers
software architect by day and home-automation enthusiast by night.
Comments