Smart Lighting Automation with Motion Sensors and Occupancy Detection

I’ve recently been exploring ways to optimize my smart lighting setup, and I wanted to share my experiences and a few tips that might help others looking to achieve similar results. My goal was to create an automation that would open my bathroom blinds in the morning when motion is detected, but only once per day to avoid any unintended behavior.

Here’s what I did:

  1. Setup and Configuration: I started by ensuring my motion sensor and blind motor were correctly integrated into my smart home ecosystem. It’s crucial to verify all connections and ensure the devices are communicating properly.

  2. Automation Logic: I created an automation that triggers when motion is detected in the bathroom after 8 AM. The automation checks the current time and day to ensure it only runs during the desired window. Here’s a snippet of the YAML configuration I used:

yaml
alias: Open Master Bathroom Blinds in AM with Occupancy
trigger:

  • platform: motion
    entity_id: binary_sensor.bathroom_motion
    condition:
  • condition: time
    after: ‘08:00:00’
    before: ‘17:00:00’
    action:
  • service: cover.set_position
    target:
    entity_id: cover.master_bathroom_blinds
    position: 100
  1. Preventing Multiple Triggers: To ensure the automation doesn’t run multiple times in a single day, I added a condition that checks if the automation has already been triggered that day. This was achieved using a simple template condition:

yaml
condition:

  • condition: template
    value_template: ‘{{ this.last_triggered.date() != now().date() }}’
  1. Testing and Refinement: After setting everything up, I thoroughly tested the automation to ensure it worked as intended. It’s important to monitor the system for a few days to catch any unexpected behavior and make adjustments as needed.

This setup has been working perfectly for me, and I hope it can provide some inspiration or guidance for others looking to implement similar smart home automation. If anyone has questions or suggestions for improvement, I’d be happy to discuss further!