I'm off to bed...
Further to my post about the sensors I have, I thought I would share my off to bed routine. While this is written in home assistant, I have ported this over from Openhab.
The first stage is a google routine called "I'm off to bed", as that is my voice prompt. This does a few actions straight off the bat . It turns off my home theater setup, sets a toggle helper on home assistant and reminds me to brush my teeth. At this point, nothing further happens.
Once I am actually ready to head to bed, I walk up my stairs, which triggers an Aqara motion sensor at the top. There is a separate home assistant routine that turns on the light when motion is detected and the light level is dim. Once motion is detected, home assistant matches the trigger with the condition that the off to bed helper is on. If everything is in place, the lights downstairs all switch off. The lights in my bedroom now switch on, the bedroom blind now closes if it was open and the helper resets.
In future, I may improve this routine by adding detection for my going in to the bathroom and / or using my toothbrush before going to bed for an extra prompt.
The code in home assistant looks like this:
alias: off to bed
description: ""
trigger:
- type: motion
platform: device
device_id: fdaa058eb984892849c4c3f47b622026
entity_id: 489a5088d425fafed85d31ee16609f6f
domain: binary_sensor
condition:
- condition: state
entity_id: input_boolean.off_to_bed
state: "on"
action:
- service: scene.turn_on
target:
entity_id: scene.blinds_down
metadata: {}
- service: scene.turn_on
target:
entity_id: scene.bedtime
metadata: {}
- type: turn_on
device_id: 0c29c0642cf82a4c696517dd912ca56e
entity_id: 9bcc9702c3624d7e69e7d855de0a3352
domain: switch
- type: turn_on
device_id: 0c29c0642cf82a4c696517dd912ca56e
entity_id: 9bcc9702c3624d7e69e7d855de0a3352
domain: switch
- service: automation.trigger
data:
skip_condition: true
target:
entity_id: automation.home_threater_off
- service: scene.turn_on
target:
entity_id: scene.downstairs_night
metadata: {}
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.off_to_bed
- type: turn_on
device_id: 1c571f29bf1ee8d2296ddd76a5f94009
entity_id: 77358d2a874b3fa37d7e75094d5a29be
domain: light
brightness_pct: 70
mode: single
About the author
Tim Wilkes is a UK-based security architect with over 15 years of experience in electronics, Linux, and Unix systems administration. Since 2021, he's been designing secure systems for a telecom company while indulging his passions for programming, automation, and 3D printing. Tim shares his projects, tinkering adventures, and tech insights here - partly as a personal log, and partly in the hopes that others will find them useful.
Want to connect or follow along?
LinkedIn: [phpsytems]
Twitter / X: [@timmehwimmy]
Mastodon: [@timmehwimmy@infosec.exchange]
If you've found a post helpful, consider supporting the blog - it's a part-time passion that your support helps keep alive.
⚠️ Disclaimer
This post may contain affiliate links. If you choose to purchase through them, I may earn a small commission at no extra cost to you. I only recommend items and services I’ve personally read or used and found valuable.
As an Amazon Associate I earn from qualifying purchases.