Automation with zwave devices - turn on light when move detect

hello everybody,
it’s my first automation so please be kind :wink:
I tried to make a simple automation for my walk-in closet.
What I need is to turn on the lights when someone enter the walk-in closet.
I have a motion sensor by fibaro and a wall plug that turn on the light. There’s something that doesn’t work. light is still on, no way to turn off. Neither with switch button on home assistant
Could you help me please?

Here’s the automation…

- alias: Turn on  light when there is movement
  trigger:
    platform: state
    entity_id: binary_sensor.fibaro_system_fgms001_zw5_motion_sensor_sensor
    to: 'on'
  action:
    service: switch.turn_on
    entity_id: switch.fibaro_system_fgwpe_f_wall_plug_gen5_switch

- alias: Turn off after last movement
  trigger:
    platform: state
    entity_id: binary_sensor.fibaro_system_fgms001_zw5_motion_sensor_sensor
    to: 'off'
    for:
      minutes: 1
  action:
    service: switch.turn_off
    entity_id: switch.fibaro_system_fgwpe_f_wall_plug_gen5_switch

Please format your code properly so we can see if there’s a spacing issue. Use three backticks (```) above and below your code.

and you’ll need to get that sorted before we can help you get a working automation.

hi all, sorry for mistake. i had fix it. Thanks

Could you please help me?
what am i doing wrong?

Looks fine, as long as the automations are on and the entity IDs are correct. As @finity said, you need to fix this issue first:

light is still on, no way to turn off. Neither with switch button on home assistant

If the switch isn’t working outside Home Assistant, that needs to be fixed first.