Problem with PIR sensor

Using a Raspberry pi. I want to turn on a LED ,when motion detected with PIR sensor ,PIR is connected as binary sensor in config.yaml
the automation code I used is

binary_sensor:
  - platform: rpi_gpio
    ports:
      4: PIR Office
      1: Garage Door


automation:
- alias: Turn on hall light when there is movement
  trigger:
    platform: state
    entity_id: binary_sensor.PIR_Office
    to: 'on'
  action:
    service: light.turn_on
    entity_id: light.lightstrip_cupboard

- alias: Turn off hall light when there is no movement
  trigger:
    platform: state
    entity_id: binary_sensor.PIR_Office
    to: 'off'
    for:
      seconds: 5
  action:
    service: light.turn_off
    entity_id: light.lightstrip_cupboard

the PIR is working as binary sensor ,in the UI get on when motion detected and off if else.
But it doesn’t control the light
so what is the wrong ?

I think you need to use lowercase in binary_sensor.PIR_Office -> binary_sensor.pir_office.

You can double check this from the “<>” button in the menu (entities used by home assistant).

I wrote it lowercase first ,and it wasn’t working also

What happens when you execute the automation manually from the GUI? That way it will skip the trigger part and skip straight to the action. If you nothing happens the problem is in your action. Else it’s the trigger.

Your automatons looking fine, so you’ll need to check it the entities you are naming.

Don’t use upper case.

PIR as binary sensor is working (on/off) , but no action with LED
and entity ID’s are correct

What happens when you execute the automation manually from the GUI? That way it will skip the trigger part and skip straight to the action. If nothing happens the problem is in your action. Else it’s the trigger.

check if your automations are enabled in HA entities.
you may need to add

initial_state: true

to both your automations to be enabled