Why is this automation turning light on when entering, but not off after 10 minutes inactivity?

Are you sure you don’t have any other automation turning on your lights?

If you go to your light under Settings > Devices and Services, you will find a box showing the last entries in the Logbook related to that device. There you can see what is turning on your light right after your automation turns it off.

Great tip. Attached two screenshots but you can see camera motion turning off then on at the same second.


Your camera is detecting the lights going off as a movement…

So any solution? And is that normal?

Well first yes, but you kept my automation ID. Remove that and it should work.

In addition, I’d do it in the GUI not in YAML since you a newbie as it will catch little issues.

Sounds like you have another issue as ur camera is catching the light going off as motion.

Is it automatically generated, the ID and if I understand it correctly it’s only purpose is so that you can edit it in the visual editor?

I wouldn’t expect any motion sensor to capture a light turning off as a motion, but if your camera is doing that, maybe you have to find a work around.
I always like more real motion sensors, even having cameras in some of the areas where I monitor for motion. :wink:

There’s always a solution, but that will require a bit more thinking for a new automation which would take in account this behavior from your camera, as some test so you discover the unknown behaviors.

Let’s try this… delete all your automations used to control this light, then go to Settings > Automations & Scenes > Create new automation > Click on the 3-dots menu at the top right and select “Edit YAML”, then paste this and save:

description: ""
mode: single
trigger:
  - id: Motion detected
    platform: state
    entity_id:
      - binary_sensor.birch_neolink_1_motion
    to: "on"
  - id: Motion stopped
    platform: state
    entity_id:
      - binary_sensor.birch_neolink_1_motion
    to: "off"
    for:
      minutes: 1
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Motion detected
          - condition: state
            entity_id: light.jasco_products_43080_light
            state: "off"
            for:
              seconds: 3
        sequence:
          - service: light.turn_on
            data: {}
            target:
              entity_id: light.jasco_products_43080_light
      - conditions:
          - condition: trigger
            id: Motion stopped
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.jasco_products_43080_light

Basically I’m repeating your original automation (just trying to put in an easier to understand format) and adding a condition to not turn on the light until it is off for at least 3 seconds.

Please let me know how this one works.

That seems to have fixed it. Thanks so much. No I’m going to study it to make sure I understand it all.

1 Like

I am not sure what the ID does, but I do know when I was first starting, I copied someone else’s automation ID and my system basically said nice try and have a nice day.

The ID simply needs to be unique in your system. If you’re using the UI editor it’ll create one behind the scenes for you.

Thank you.

Take a look at this post about unique_id and entity_id: