Weird events this morning!

I was rudely awakened this morning at 05:38:03 by the en-suite bathroom lights switching on and off rapidly. They are switched by one half of a Fibaro dual relay connected to the light switch. The second half of the relay controls the bathroom fan, which was also switching on and off in time with the lights.The fan is turned on by an automation when the lights are turned on. Trying to switch the lights off with the wall switch or via the HA phone app wouldn’t work so I eventually restarted Home Assistant which solved the problem. This is the second time this has happened since I set this up a few months ago. Here are the entries from the Logbook:

You can see that the lights were turned on by homeassistant and then the automation turned on the fan. Homeassistant then turned off both devices and the cycle repeated. The fan is only supposed to be turned off by the automation if the humidity drops below 68% or after 20 minutes. Here are the automations:

- id: '1590089687316'
  alias: EnSuite Bathroom Fan On
  description: Turn on the EnSuite fan with the lights.
  trigger:
  - device_id: e73a7e3120cd4492a2abc76a102d37db
    domain: switch
    entity_id: switch.fibaro_fgs221_ensuite_lights
    platform: device
    type: turned_on
  condition: []
  action:
  - data: {}
    entity_id: switch.fibaro_fgs221_ensuite_fan
    service: switch.turn_on
  mode: single
- id: '1590090015878'
  alias: EnSuite Bathroom Fan Off
  description: Turn off the EnSuite fan after 20 minutes if humidity is low enough.
  trigger:
  - device_id: e73a7e3120cd4492a2abc76a102d37db
    domain: switch
    entity_id: switch.fibaro_fgs221_ensuite_lights
    for:
      hours: 0
      minutes: 20
      seconds: 0
    platform: device
    type: turned_off
  - below: '68'
    entity_id: sensor.ensuite_ble_humidity
    for: 0:20:00
    platform: numeric_state
  condition: []
  action:
  - data: {}
    entity_id: switch.fibaro_fgs221_ensuite_fan
    service: switch.turn_off

Anyone have any thoughts on this?