How to restart automation (stop motion) is started and when there is motion it restart

hope sombody can help i just started to move over to home assistant.
And got stuck with an issue i made two automation one for turning on and one for turning off the lights when there is no motion detected. i tried looking around but could not get it to work.

with little step by step. i think ill figure out how it works HA

products i got 2x aqara motion sensor and 1x aqara wall switch both conected through zigbee HA

thank you
will this also restart when there is motion detected again. like motion detected enter room pick a glass and go back to motion area then it restarts ? and not turn off while i am walking back to the kitchen again.
so the text i need to add it to here ? then
and light.your_light_here mine is light switch wil this work when i change it to entity: switch.0x54ef441000367476

Hey thanks for your answer it tried but lights are not turning on

this is what i added. But lights is not turning on i have a light switch from Aqara wall switch h1 if this helps

description: “Licht Aan of uit”

  • platform: state
    entity_id: binary_sensor.0x54ef441000637130_occupancy # change this
    to: ‘on’
  • platform: state
    entity_id: binary_sensor.0x54ef441000637130_occupancy # change this
    to: ‘off’
    minutes: 1 # adjust as necessary
  • service: “light.turn_{{ trigger.to_state.state }}”
    entity_id: switch.0x54ef441000367476 # change this
    mode: single

Your entity is a switch not a light so change this:

service: "light.turn_{{ trigger.to_state.state }}"

To this:

service: "switch.turn_{{ trigger.to_state.state }}"
1 Like

Thank you for the info

i already figure it out that light needed to change to switch when checking naming of device