Turn off light after door locks

I’m speechless… Don’t know what’s wrong in my automation
I want to turn off some light when a door is locked.
My setup is a door lock controlled with Zwave (Danalock brand) and Dimmer controlled via MQTT.
Home assistant can control with no issue everything (lock and unlock, turn on and turn off light).
I’m on hass.io 0.88.0
I did this automation :

- id: '1550785973821'
  alias: Turn off light after door locked
  trigger:
  - entity_id: lock.polycontrol_danalock_v3_locked_avant
    from: unlocked
    platform: state
    to: locked
  condition: []
  action:
  - delay: 0:00:15
  - data:
      entity: light.vestibule
    service: light.turn_off
  - data:
      entity: light.murale_exterieur_avant
    service: light.turn_off

But it don’t work at all… what am I missing

I would recommend against using the automation editor. It has issues and the generated code is difficult to read. Try this:

- id: '1550785973821'
  alias: Turn off light after door locked
  trigger:
    - platform: state
      entity_id: lock.polycontrol_danalock_v3_locked_avant
      to: locked
      for:
        seconds: 15
  action:
    - service: light.turn_off
      entity: light.vestibule
    - service: light.turn_off
      entity: light.murale_exterieur_avant

Use the developer tools states menu (<> button lower left) to confirm your lock states are actually “locked” and “unlocked”.

and you can make it even simpler (needed to replace “entity:” with “entity_id:” too…I think)

- id: '1550785973821'
  alias: Turn off light after door locked
  trigger:
    - platform: state
      entity_id: lock.polycontrol_danalock_v3_locked_avant
      to: locked
      for:
        seconds: 15
  action:
    - service: light.turn_off
      entity_id: 
        - light.vestibule
        - light.murale_exterieur_avant

No luck…

But got the idea to restart completely Home Assistant and bingo, it work… Thank You

Then started Node-RED (was trying it) and it stopped working… than some lights will come on for no reason, one light was part of an automation in Node-RED, so was putting the fault on a bad setting from me, but 3 lights were turning on for no reason, 2 are from the automation of this topic (not in Node-RED), and one other was not part of any automation at all. and the weirdest think is that Home Assistant won’t receive the Mqtt signal that the light is turned on.

Now that I removed Node-RED, 2 of the lights are stopped to misbehave, but the 2 from this automation are still reluctant, but don’t light up as often than with Node-RED.

All dimmer are exactly the same model (there’s more than 30 all over the house), all have Tasmota 6.4.1, all are connected to the same SSID, all have the same GEO, TIME, NST SERVER and POWER Retain 1… In fact I used the Tuya over the air method to flash. Then set one with my parameter, save the config, then upload the config to the others then change the Friendly Name and MQTT topic. All have the same YAML config. and all work well with Home Assistant.

Really weird…