Motion off does not trigger an event

I have just started with Hass and would love some hlep
I have created two automation actions, the first one works like a charm but second one does not.

  • id: ‘1526638432937’
    alias: Kitchenlighton
    trigger:

    • entity_id: binary_sensor.motion_sensor_158d0001643b68
      from: ‘off’
      platform: state
      to: ‘on’
      condition:
    • condition: state
      entity_id: binary_sensor.motion_sensor_158d0001643b68
      state: ‘on’
      action:
    • data:
      entity_id: switch.plug_158d0001f24b6f
      service: switch.turn_on
  • id: ‘1526641363666’
    alias: Light off
    trigger:

    • entity_id: binary_sensor.motion_sensor_158d0001643b68
      from: ‘on’
      platform: state
      to: ‘off’
      condition:
    • condition: state
      entity_id: binary_sensor.motion_sensor_158d0001643b68
      state: ‘Off’
      action:
    • data:
      entity_id: switch.plug_158d0001f24b6f
      service: switch.turn_off

I can see in my sensor turning off but it does nto trigger the event to turn off the switch

5:19 PM
Sun has set
5:18 PM
yr Symbol changed to 5
4:34 PM
Sensor.Kitchen turned off
4:32 PM
Plug_158d0001f24b6f turned on
4:32 PM
lighton has been triggered
4:32 PM
Sensor.Kitchen turned on

Any help will be appreciated

First please use code block when posting code (see blue box on top of your post) or use the < / > botton.

As for your automation change state: Off to state: off in the condition. Actually I think you can remove the condition completely.