ESPHome node giving API encryption error when calling service

I have an ESP32 device that I have just flashed using ESP web
It has been discovered by HA, and I have flashed a basic config to the device from the ESPHome HA web portal

I have ensured that the API key in the yaml matches the string given to me when HA discovered the device

I have ensured that the “Allow device to call HA services” checkbox is ticked

However, whatever I do, I get the following error whenever I try to update a sensor using the API:

Logger: aioesphomeapi.connection
Source: runner.py:179
First occurred: 15:18:25 (16 occurrences)
Last logged: 15:55:25

192.168.1.158: Connection error occurred: Connection requires encryption
esphome-web-065eb0 @ 192.168.1.158: Connection error occurred: [Errno 104] Connection reset by peer
192.168.1.158: Connection error occurred: Invalid encryption key: received_name=esphome-web-065eb0
esphome-rain @ 192.168.1.158: Connection error occurred: [Errno 104] Connection reset by peer
192.168.1.158: Connection error occurred: Invalid encryption key: received_name=esphome-rain

And the code itself:

esphome:
  name: "esphome-rain"
  friendly_name: ESPHome Web 065eb0

  on_boot: 
    then:
      - wait_until:  
           condition:      
             api.connected: 
              
      - homeassistant.service:
          service: counter.increment
          data:
           entity_id: counter.total_tips 
           
esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "OXJawYNUs87X94Don83ACc4jV8U9XlQhVNGDqaqpfzg="

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-065Eb0"
    password: "3fZXCesDocqb"

captive_portal: