Smart Lighting Automation with Hue: Seeking Feedback!

I’m really excited about my latest project with Home Assistant! I’ve been working on setting up a smart lighting system using Hue lights with motion sensors and time-based conditions. It’s been a fun challenge, and I wanted to share my setup and ask for feedback to see if there’s a more efficient way to achieve this.

Here’s what I’ve done so far:

  1. Motion Detection: I’ve set up motion sensors in my hallway to trigger the lights when someone enters.
  2. Time-Based Scenes: Depending on the time of day (morning, day, evening, night), the lights switch to different scenes for optimal lighting.
  3. Automation: The system turns off the lights after 30 seconds of no motion, which is working smoothly.

I created a template sensor to combine two motion sensors into one, which simplifies the automation process. Here’s a snippet of my automation setup:

yaml
alias: Hallway Lighting Automation
trigger:

  • platform: state
    entity_id: sensor.hallway_motion
    to: ‘on’
  • platform: state
    entity_id: sensor.hallway_motion
    to: ‘off’
    for: ‘00:00:30’
    action:
  • choose:
    • conditions:
      • condition: state
        entity_id: sensor.hallway_motion
        state: ‘on’
      • condition: state
        entity_id: sensor.time_of_day
        state: ‘day’
        sequence:
      • service: hue.activate_scene
        data:
        group_name: Hallway
        scene_name: Bright
    • conditions:
      • condition: state
        entity_id: sensor.hallway_motion
        state: ‘on’
      • condition: state
        entity_id: sensor.time_of_day
        state: ‘night’
        sequence:
      • service: hue.activate_scene
        data:
        group_name: Hallway
        scene_name: Night Light
    • conditions:
      • condition: state
        entity_id: sensor.hallway_motion
        state: ‘off’
        sequence:
      • service: light.turn_off
        data:
        entity_id: light.hallway

This setup works well, but I’m curious if there’s a more efficient way to handle the time-based conditions or if I can reuse this automation for multiple rooms without duplicating the code. I’m also exploring the Python integration and AppDaemon to potentially streamline this further.

If anyone has tips or alternative approaches, I’d love to hear them! The possibilities with Home Assistant are endless, and I’m excited to keep learning and improving my setup. :blush: