Do I need boolean

Hello Automaters,

I have a PIR sensor which when motion is detected it switches on 2 lights, then after 2 mins of not detecting movement the lights switch off which is covered by the 2 automations below.
I also have a seperate routine activated by saying

“OK Google, turn on upstairs lights”

part that routine switches on the same 2 lights.

The problem I am experiencing is when i have activated the lights via Google i want them to stay on but when the PIR senses motion, two minutes later the lights switch off.
From what i have read in forums and HA Integrations , a boolean input may help but i have no idea where to start to be honest and I wonder if anyone can help with a bit of code to start me off.

My HA automation is as follows which works fine.

- id: 'xxxxx'
  alias: Turn on upstairs lights when there is movement
  description: ''
  trigger:
  - entity_id: binary_sensor.sonoff_pir_2
    platform: state
    to: 'on'
  condition:
  - after: '17:30'
    before: '23:59'
    condition: time
  action:
  - data: {}
    entity_id: switch.dave_s_light
    service: switch.turn_on
  - entity_id: switch.lynsey_s_light
    service: switch.turn_on
- id: 'xxxxx'
  alias: Turn off upstairs lights 2 mins after last movement
  description: ''
  trigger:
  - entity_id: binary_sensor.sonoff_pir_2
    for: 00:02:00
    platform: state
    to: 'off'
  condition: []
  action:
  - data: {}
    entity_id: switch.dave_s_light
    service: switch.turn_off
  - entity_id: switch.lynsey_s_light
    service: switch.turn_off

Thanks all, please prod and poke me if you need further information.

Just add a condition to your PIR

  condition:
  - after: '17:30'
    before: '23:59'
    condition: time
  # Only have this trigger if the lights were off. If they were already on, 
  # ignore this automation.
  - condition: state
    entity_id: switch.lynsey_s_light
    state: 'off'

Now the PIR will only do the auto off if it was the one that turned them on.

@jocnnor will give that go shortly (wife will go mad if I turn the telly off now) often it’s more simpler than it seems, thanks