Plug flicks off and on quickly - fault?

New to ESP Home but I re-flashed a few smart plugs from tasmota. One in-particular has a weird thing happening since.

Its got the code as copied below, but every so often it will flick off and on really quick. Like a switch being rocked off and on. Its powering my desk and so computer is attached. It isn’t usually enough of a power off to do anything, the light flickers, occasionally the monitor might go off and on.

What is best way to fault find?

The code on plug:

# Gosund UP111
substitutions:
  name: "plug11-office-desk"
  friendly_name: "Plug11 OFFICE DESK"
  main_icon: "power-socket-uk"
  default_state: "RESTORE_DEFAULT_OFF"
  # Activity State Threshold
  # Threshold (number) that the device will change from `Idle` to `Active` if power is greater than or equal to
  activity_threshold: "5"

esphome:
  name: ${name}

esp8266:
  board: esp01_1m
  restore_from_flash: True

preferences:
  flash_write_interval: 5min

time:
  - platform: sntp
    id: sntp_time
# Enable logging
logger:

# Enable Home Assistant API
api:
#  encryption:
#    key: "zvry/EQrIIve16vKpCMOv9zy0/UFNa8R2JvLNXHQBTU="
  encryption:
    key: !secret esphome_encryption_key

ota:
  password: "498fc0d155a38f94ebfd0ea9abdec9c8"

#web_server:
#  port: 80

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.0.87
    gateway: 192.168.0.1
    subnet: 255.255.255.0
  ap:

captive_portal:

binary_sensor:
  # Push Button (Toggles Relay When Pressed)
  - platform: gpio
    pin:
      number: GPIO3
      mode: INPUT_PULLUP
      inverted: true
    name: "${friendly_name} Button"
    on_press:
      - switch.toggle: relay
  - platform: status
    name: "${friendly_name} Server Status"

switch:
  # Relay (As Switch)
  - platform: gpio
    name: "${friendly_name}"
    icon: "mdi:${main_icon}"
    pin: GPIO14
    id: relay
    restore_mode: "${default_state}"
    on_turn_on:
      - light.turn_on:
          id: led
          brightness: 100%
          transition_length: 0s
    on_turn_off:
      - light.turn_off:
          id: led
          transition_length: 0s

sensor:
  # WiFi Signal Sensor
  - platform: wifi_signal
    name: "${friendly_name} WiFi Status"
    update_interval: 60s
  # Power Monitoring
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: true
    cf_pin: GPIO4
    cf1_pin: GPIO05
    change_mode_every: 3
    update_interval: 15s
    voltage:
      name: "${friendly_name} Voltage"
      id: voltage
      unit_of_measurement: V
      accuracy_decimals: 1
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 602.87506 -> 229.9
            - 609.8 -> 232.8
    power:
      name: "${friendly_name} Power"
      id: power
      unit_of_measurement: W
      accuracy_decimals: 0
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 1.14
            - 62.06167 -> 10.93
            - 1503.27161 -> 247.6
            - 1599.81213 -> 263.7
            - 3923.67700 -> 631.4
            - 7109.50928 -> 1148.0
            - 7237.0857 -> 1193.0
            - 7426.71338 -> 1217.0
    current:
      name: "${friendly_name} Current"
      id: current
      unit_of_measurement: A
      accuracy_decimals: 3
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.013
            - 0.08208 -> 0.071
            - 1.34223 -> 1.066
            - 5.57170 -> 4.408
            - 6.69184 -> 5.259
            - 6.97187 -> 5.540
  # Total daily energy sensor
  - platform: total_daily_energy
    name: "${friendly_name} Daily Energy"
    power_id: power
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh

text_sensor:
  # Device Activity State
  # e.g. shows as active if power reading above a certain threshold
  - platform: template
    name: "${friendly_name} Activity State"
    icon: "mdi:${main_icon}"
    lambda: |-
      if (id(power).state >= $activity_threshold) {
        return {"Active"};
      } else {
        return {"Idle"};
      }
    update_interval: 15s

# Relay State LED
output:
  - platform: esp8266_pwm
    id: state_led
    pin:
      number: GPIO1
      inverted: true

light:
  - platform: monochromatic
    output: state_led
    id: led

status_led:
  pin:
    number: GPIO13
    inverted: True    `Preformatted text`

Highly recommended for all GPIO binary sensors to use

binary_sensor:
  - platform: gpio
    filters:
      - delayed_on: 30ms

to lower interference and flickering.

30ms is an example, can try other timings too.

Thanks, worth a try.

Where would that go in the code, anywhere, so long as its inline with the items like binary_sensor: and switch:?

or like this: