Computer Startup Turns on Office Lights

Computer Startup Turns on Office Lights Featured Image

Home Assistant has some useful features built in, even if they’re not particularly well presented.

For example, you can actually trigger any automation from a basic HTTP GET request via a Webhook.

All from the GUI, without messing with endless YAML.

Toggle my Office Lights with my Computer

My plan is to have my office lights turn on and off along with my computer.

i.e. When the computer starts up; I want the desk lamp, floor lamp and wall lights to come on. When the computer is shutdown; I want them to turn off again too.

1. Create a Home Assistant “Helper” Device

In Home Assistant under Settings -> Devices & Services -> Helper Tab create a new Helper with the type of “Group”.

You can set it as a “light” or a “switch”, then add all the lamps or lights you want grouped together under this one helper device.

2. Create a Home Assistant “Automation”

In Home Assistant under Settings -> Automations & Scenes -> Automations Tab create a new automation.

Add a “Webhook Trigger” in this new automation. Clicking on the Gog icon allows you to select which HTTP methods you want. Choose “GET” and “only accessible from the local network”.

Then click the copy icon next to the Webhook ID. This will actually copy the full webhook URL rather than just the ID. It will likely be your Home Assistant IP followed by an auto generated webhook API path.

For the awkwardly named “Then do” section, select “Switch” or “Light” depending on how you created your helper in Step 1. Then select; “Toggle”, “Turn Off” or “Turn On” as you like.

Save it, then pick “run” via the 3-dot menu to test it.

3. Call the Webhook URL to Trigger the Automation.

Exactly how to call the webhook URL from your computer starting up and shutting down will depend on your setup. e.g. macOS or Linux with which Desktop Environment etc.

e.g. on Linux Mint running Cinnamon, there’s a handy “Startup Applications” app where you can add custom commands.

Once you work out how to run a command at startup and/or on shutdown. You can use a command as simple as this curl:

curl -s -o /dev/null ""

This will call the webhook with a simple GET method, silently -s, and discard any output -o /dev/null.

You’ll need to make sure to use the webhook URL you copied earlier, above is just an example.

Comments & Questions

Reply by email to send in your thoughts.

Comments may be featured here unless you say otherwise. You can encrypt emails with PGP too, learn more about my email replies here.

PGP: 9ba2c5570aec2933970053e7967775cb1020ef23