Bathroom humidity control automation issue

Hi,
I have an automation that switches on the fan when humidity is above 70%.

Our bathroom extractor is connected to lights so whenever lights are switched on the fan kicks in and when the lights are switched on the fan keeps running for another 30 minutes.
To the back of the light switch I have fitted a microswitch and that is controlled by HA.

The automation should only start when the humidity is above 70% and lights were turned off for 30 minutes.
However I have noticed that if the bathroom is in use, and the lights are turned on, the automation kicks in and switches the lights off.

My automation:

alias: "Bathroom - Humidity control "
description: Turn on lights/fan when humidity above 70%
trigger:
  - platform: state
    entity_id:
      - sensor.ble_humidity_gvh5075_403a
condition:
  - condition: state
    entity_id: switch.bathroom_lights
    state: "off"
    for:
      hours: 0
      minutes: 30
      seconds: 0
  - condition: numeric_state
    entity_id: sensor.ble_humidity_gvh5075_403a
    above: "70"
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.bathroom_lights
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.bathroom_lights
mode: restart

Where am I going wrong?

It could be that the automation is being triggered multiple times. Have you tried changing mode to single?

I think the combination of your trigger and the mode is the issue here. When you use a State trigger without a defined to:, from:, or attribute: the trigger fires every time the state or any attribute changes.

It also seems like you might be using the wrong event as your trigger. The event in time that would be closest to execution of the action would be the lights being off for 30 minutes. To put it another way… how likely is it that the lights would have already been off for 30 minutes and the humidity climbs from below 70% to above 70%? If you want to cover all the bases, use both as triggers:

alias: "Bathroom - Humidity control "
description: Turn on lights/fan when humidity above 70%
trigger:
  - platform: state
    entity_id: switch.bathroom_lights
    to: "off"
    from: "on"
    for:
      hours: 0
      minutes: 30
      seconds: 0
  - platform: numeric_state
    entity_id:
      - sensor.ble_humidity_gvh5075_403a
    above: 70
condition:
  - condition: state
    entity_id: switch.bathroom_lights
    state: "off"
    for:
      hours: 0
      minutes: 30
      seconds: 0
  - condition: numeric_state
    entity_id: sensor.ble_humidity_gvh5075_403a
    above: 70
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.bathroom_lights
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.bathroom_lights
mode: single