Last active
November 20, 2025 02:38
-
-
Save mutovkin/47b70f7c44e7b98b9e57d9db60f8af6e to your computer and use it in GitHub Desktop.
Motion-activated Light with sun condition (ANY binary_sensor)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: Motion-activated Light with sun condition (ANY binary_sensor) | |
| description: Works with motion OR occupancy sensors (true/false or on/off). Supports both light and switch entities. | |
| domain: automation | |
| input: | |
| motion_entity: | |
| name: Motion / Presence Sensor | |
| selector: | |
| entity: | |
| domain: binary_sensor | |
| # No device_class filter → accepts occupancy too | |
| light_target: | |
| name: Light or Switch | |
| selector: | |
| target: | |
| entity: | |
| domain: | |
| - light | |
| - switch | |
| no_motion_wait: | |
| name: Wait time | |
| description: Time to leave the light on after last motion is detected. | |
| default: 120 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 3600 | |
| unit_of_measurement: seconds | |
| sunset_offset: | |
| name: Offset to turn on lights | |
| description: Define offset to sunset | |
| default: 60 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 240 | |
| unit_of_measurement: minutes | |
| sunrise_offset: | |
| name: Offset to turn off lights | |
| description: Define offset to sunrise | |
| default: 45 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 240 | |
| unit_of_measurement: minutes | |
| mode: restart | |
| max_exceeded: silent | |
| trigger: | |
| - platform: state | |
| entity_id: !input motion_entity | |
| # Accept any "on-like" state | |
| to: "on" | |
| - platform: state | |
| entity_id: !input motion_entity | |
| to: "true" | |
| condition: | |
| - condition: or | |
| conditions: | |
| - condition: sun | |
| after: sunset | |
| after_offset: !input sunset_offset | |
| - condition: sun | |
| before: sunrise | |
| before_offset: !input sunrise_offset | |
| action: | |
| - service: homeassistant.turn_on | |
| target: !input light_target | |
| - wait_for_trigger: | |
| - platform: state | |
| entity_id: !input motion_entity | |
| to: "off" | |
| - platform: state | |
| entity_id: !input motion_entity | |
| to: "false" | |
| - delay: !input no_motion_wait | |
| - service: homeassistant.turn_off | |
| target: !input light_target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment