Automating Sleep Mode With Withings Presence + Home Assistant Blueprints

Over the past few years I’ve standardized most of my Home Assistant automation around two ideas: explicit state modeling and reusable blueprints. Sensors, switches, helpers should be extracted for every automation.

This blog post walks through a low-noise, robust sleep automation pattern using a Withings presence sensor, a simple state helper, and two small YAML blueprints.

Code and blueprints referenced here are available under Amantux/HomeAssistantBluePrints on GitHub:


Why a Helper?

A lot of automations trigger directly on a sensor state change which works fine until you get a flicker or an odd state. Withings presence is great at detecting “in bed” but it’s not perfect. I’ve run into problems placing heavy books, doing my laundry or taking a quick 15 minute nap.

Rather than have every automation check binary_sensor.withings_in_bed, I use an input_boolean.bed_mode as the canonical sleep state. This gives me:

  • A single source of truth that all automations can key off
  • The ability to debounce raw sensor noise
  • A clean separation between detection and intent

This is the same pattern I used in other parts of my Home Assistant setup, where sensors feed state helpers and the rest of the logic consumes the helper output.


How It Works

There are two simple automations:

1. Turn Sleep Mode ON

Only if you’re in bed long enough, and optionally only within a time window.

Conceptually:

If Withings sensor is ON
AND it stays ON for ≥ X minutes
(Optionally: AND the current time is within a window)
→ Turn ON input_boolean.bed_time

This avoids flipping sleep mode on just because you sat on the bed for a moment.

The key fields are:

  • Duration: how long to wait before turning sleep on
  • Time gate: optional start/end time window to restrict when sleep mode engages

2. Turn Sleep Mode OFF

Only if you’ve actually left the bed.

Conceptually:

If Withings sensor is OFF
AND it stays OFF for ≥ Y minutes
(Optionally: AND the current time is in a morning window)
→ Turn OFF input_boolean.sleep_time

This prevents a brief out-of-bed moment from taking your entire automations out of sleep mode.

The fields match the ON blueprint:

  • Delay before turning off
  • Optional time gate
  • Safety check: only turn off if still out of bed

Putting It Into Your Home Assistant

  1. Import the blueprints
    Settings → Automations & Scenes → Blueprints → Import Blueprint
    Then paste the raw GitHub YAML URL.
  2. Create automations from the blueprints
    Configure how long before sleep mode should be engaged/disengaged, and whether a time gate applies.
  3. Use input_boolean.bed_mode in your other automations
    Instead of checking the sensor directly, use this helper as a reliable indicator of “sleep state”.

This pattern lets me do things like:

  • Disable motion lighting during sleep
  • Quiet notifications after a certain time
  • Adjust HVAC targeting based on real sleep state

Benefits

  • Debounced logic — no noise from pop-in/out sensor events.
  • Clear separation of intent — detection vs state.
  • Reusable blueprints — configurable inputs and time gates.
  • State-driven system — everything else in HA keys off a simple boolean.

If you’re pushing past sensor noise into robust state automation, this pattern should fit into your stack gracefully.

Leave a Reply

Your email address will not be published. Required fields are marked *