Seeking Advice on Sleep-Focused Lighting with Home Assistant

Hello everyone,

Interested in enhancing our sleep routine. At first, I imagined simulating sunlight in the morning and moonlight at night using my TPLink Kasa LED strips. It could be pretty simple, just create a bunch of scenes that are say a light purple dimmed (30%,20%,10% etc) and then make automations based on time that run on the led strip…I’ve been encountering some challenges with the integration though. The LEDs frequently drop out of Home Assistant unexpectedly, which will disrupt my planned lighting sequences.

I’m curious to know if others have a reliable setup in this context. What hardware are you using for your lighting automation? Are there alternative smart devices or brands that have proven to be more reliable than TP-Link Kasa?

If anyone is willing to share their automation configurations in YAML, I would greatly appreciate it. Seeing examples would be awesome.

Thanks!

I currently use HUE bulbs for the bedside lamps and my lounge room corner lamp and a HUE led strip at the top edge of my bathroom since my main light is just pure white LED and has the exhaust fan tied to it’s on and off state.

These HUE devices are then linked to the Circadian custom intergration.

I then use a aqara leak sensor set to occupancy mode and use a pressure mat connected to its screws to trigger states when I am in or out of bed (added benefit of letting me track my sleep hours).

These states then trigger to turn off all the lights in the home, disable motion sensor automation’s, turn on my air purifier to help me sleep, put the PC monitors to sleep using hass agent mqtt command and if my alarm is enabled on my phone via hassalarm state update push and I am have been in bed for more than 5min and the alarm is set between 6a and 12p on a weekday then it toggles the on state for the switch to use the bedroom HUE bulbs to turn on when the alarm goes off which is using the circadian system to apply the correct color and temperature settings automatically.

alias: Bed Occupancy Automations
description: ""
trigger:
  - type: not_locked
    platform: device
    device_id:
    entity_id:
    domain: binary_sensor
    id: Latch State - Unlocked
  - type: occupied
    platform: device
    device_id:
    entity_id:
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 31
    id: Occupied - 30s
  - type: occupied
    platform: device
    device_id:
    entity_id:
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
    id: Occupied - 5min
  - type: not_occupied
    platform: device
    device_id:
    entity_id:
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 11
    id: Unoccupied - 10s
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Occupied - 30s
        sequence:
          - service: automation.turn_off
            metadata: {}
            data:
              stop_actions: true
            target:
              entity_id:
                - automation.bedside_lamps_toggle
                - automation.bathroom_humidity_management
          - service: light.turn_off
            metadata: {}
            data: {}
            target:
              area_id:
                - bathroom
                - bedroom
                - kitchen
                - living_room
          - device_id:
            domain: button
            entity_id:
            type: press
      - conditions:
          - condition: trigger
            id:
              - Occupied - 5min
        sequence:
          - service: input_boolean.turn_on
            target:
              entity_id: input_boolean.alarm_toggle
            data: {}
      - conditions:
          - condition: trigger
            id:
              - Unoccupied - 10s
        sequence:
          - service: automation.turn_on
            data: {}
            target:
              entity_id:
                - automation.bedside_lamps_toggle
                - automation.bathroom_humidity_management
          - service: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.alarm_toggle
      - conditions:
          - condition: trigger
            id:
              - Occupied - 30s
          - condition: and
            conditions:
              - condition: trigger
                id:
                  - Latch State - Unlocked
        sequence:
          - service: notify.mobile_app_rkphone
            data:
              title: Door Lock
              data:
                notification_icon: mdi:lock-smart
                color: red
              message: Front Door Nightlatch is unlocked!
mode: single

alias: Alarm Clock
description: ""
trigger:
  - platform: time
    at: input_datetime.next_alarm
condition:
  - condition: state
    entity_id: input_boolean.alarm_toggle
    state: "on"
    enabled: true
  - condition: and
    conditions:
      - condition: time
        after: "06:00:00"
        before: "12:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
action:
  - service: light.turn_on
    target:
      label_id: bedside_lamps
    data:
      transition: 60
mode: single
alias: Alarm Clock Toggle
description: ""
trigger:
  - platform: state
    entity_id:
      - input_boolean.alarm_toggle
    from: "off"
    to: "on"
    id: Alarm on
  - platform: state
    entity_id:
      - input_boolean.alarm_toggle
    from: "on"
    to: "off"
    id: Alarm off
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Alarm on
        sequence:
          - service: automation.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: automation.alarm_clock
      - conditions:
          - condition: trigger
            id:
              - Alarm off
        sequence:
          - service: automation.turn_off
            target:
              entity_id: automation.alarm_clock
            data:
              stop_actions: true
mode: single

This should get you and others pointed in the right direction for your setup needs based on what I have setup so far.

1 Like