Door Sensor - Turn on/off Light

I changed the default motion sensor blueprint to match door sensors!
Turn on porch-, -garage or door lights when door opens. Leave it on for X seconds after closing the door.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

  name: Door Sensor-activated Light
  description: Turn on a light when door is opened.
  domain: automation
      name: Door Sensor
          domain: binary_sensor
# My sensors has device_class opening but it's commented 
# for now since not every sensor uses 'opening' as default
#          device_class: opening
      name: Light
            domain: light
      name: Wait time
      description: Time to leave the light on after door is closed
      default: 120
          min: 0
          max: 3600
          unit_of_measurement: seconds

mode: single
max_exceeded: silent

  platform: state
  entity_id: !input doorsensor_entity
  from: "off"
  to: "on"

  - service: light.turn_on
    target: !input light_target
  - wait_for_trigger:
      platform: state
      entity_id: !input doorsensor_entity
      from: "on"
      to: "off"
  - delay: !input door_closed_wait
  - service: light.turn_off
    target: !input light_target


device_class: door should be also included as accepted input for Door Sensor.

Of course! Ehm, I’ve been looking around and can’t seem to see how do you set multiple device_classes. Do you have any idea? Or should I just delete that row and let people choose from all the binary_sensors?


From the looks of it entity device_class selector only accepts a single value.
Until they allow multiple device classes my suggestion would be that yes, delete that row.

My zigbee door sensors have the “door” device_class set, so this blueprint would not be able to use them.

what if i need to switch on off sonoff t1? :slight_smile: isnt on the light list

I see The dilemma but if I take away yet another domain it takes away the simplicity. You can just copy the code and either delete the domain or change it to switch and save locally :slightly_smiling_face:

Looks good, just no use for me, because my sonoff is not recognized as light.

I guess i can make another blueprint that uses homeassistant.turn_on/off so you can mix lights, switches and… Whatever.

I might have a little time tonight, or not. I post the link here when it is done

I actually just thought I said it … Why does he see my tasmotas as a switch and not as a light, this was very simple …
i had to use another discovery function.

Now I have used setOption30 1, and then he sees them …

Problem solved.

ok, works

  name: Switch
        domain: switch


  • service: homeassistant.turn_on
    target: !input light_target
  • wait_for_trigger:
    platform: state
    entity_id: !input doorsensor_entity
    from: “on”
    to: “off”
  • delay: !input door_closed_wait
  • service: homeassistant.turn_off
    target: !input light_target

I adding the time condition for active/in-active the automation.

      name: Timer active start
      description: Time to start the automation!
      default: 07:00:00
        time: {}
      name: Time active stop
      description: Time to stop the automation
      default: 07:00:00
        time: {}
  - condition: time
    after: !input 'time_active_start'
    before: !input 'time_active_stop'
1 Like

Great idea! Should absolutely be implemented in the blueprint.

Allthough, time is rare with 2 kids and christmas around the corner :slightly_smiling_face:

1 Like

Really good automation.

Would be nice if you can allow the switch class as well instead of just the light class

1 Like

Do you know if you can use multiple domains or do I need to remove the domain info?

1 Like

What about from sunset to sunrise? is it possible? sorry if it’s a noob questions?

You could change the “time” to “sun” condition.

  - condition: sun
    after: sunrise
    before: sunset
1 Like

thanks @thangnm,
I managed to do it with

  - condition: state
    entity_id: sun.sun
    state: 'below_horizon'

not sure if it’s ok to use it like this, but seem to works

1 Like

looks to be a great Blueprint, just wondering how to import it into HA, so which URL should I use to import this Blueprint?
Tx - Dave

Hey, I’m sorry about the late reply. Just use the URL you see in the top. Or copy this one :slight_smile:

I added the door sensor light on/off blueprint to my home assistant but when I go to choose a device or area I get “No matching devices found” any idea as to why this is happening? I am trying to add my z-wave light switch which I have connected to my home assistant.