Shelly Plug 2 automation randomly switches via "unavailable" to "on" instead of going to "off"

Hi all

This automation which is supposed to turn a shelly plug 2 back off after 20 min only works about every other time (cannot recognize a pattern when it works and when it does not). When it does not work it instead will cause the device to become unavailable and 1 second later to switch back from unavailable to on:

id: '1666134614470'
alias: Zirkulationspumpe_aus_nach_20min
description: ''
trigger:
  - platform: device
    type: turned_on
    device_id: e6f757096e20cc19499300cb8ae0c755
    entity_id: switch.heizraum_shellyplug
    domain: switch
    for:
      hours: 0
      minutes: 20
      seconds: 0
condition: []
action:
  - type: toggle
    device_id: e6f757096e20cc19499300cb8ae0c755
    entity_id: switch.heizraum_shellyplug
    domain: switch
mode: single

I have no other device unavailability issues. It seems the automation is causing the device
unavailability. When the automation fails, the logbook has 2 entries with 1 second time difference:

(1) “ShellyPlug-Zirkulationspumple unavailable triggered by automation Zirkulationspumple_aus_nach20min …[translated from German]”
(2) “ShellyPlug-Zirkulationspumple on triggered by automation Zirkulationspumple_aus_nach20min …[translated from German]”

When the automation works I have only the one expected entry that the plug went off triggered by the automation.

I use unicast and entered the local IP and port to the ColoT peer field.

Here my attempt to filter the relevant message from the log:

2022-10-22 06:50:00.231 DEBUG (MainThread) [homeassistant.components.shelly] Setting state for entity ShellyPlug-Zirkulationspumpe, state: {‘turn’: ‘off’}
2022-10-22 06:50:00.232 DEBUG (MainThread) [aioshelly.block_device] aiohttp request: /relay/0 (params={‘turn’: ‘off’})
2022-10-22 06:50:01.507 DEBUG (MainThread) [aioshelly.coap] CoapMessage: ip=192.168.2.72, type=periodic(30), payload={‘G’: [[0, 9103, 0], [0, 1101, 1], [0, 4101, 0.0], [0, 4103, 0], [0, 6102, 0], [0, 6109, 0.0]]}
2022-10-22 06:50:01.507 DEBUG (MainThread) [aioshelly.coap] Calling CoAP message update for device 192.168.2.72
2022-10-22 06:50:01.508 DEBUG (MainThread) [homeassistant.components.shelly] Manually updated ShellyPlug-Zirkulationspumpe data
2022-10-22 06:50:02.217 ERROR (MainThread) [homeassistant.components.shelly] Setting state for entity ShellyPlug-Zirkulationspumpe failed, state: {‘turn’: ‘off’}, error: ClientOSError(104, ‘Connection reset by peer’)

Any help would be highly appreciated. Action type “turn_off” instead of “toggle” gives the same result.

Home Assistant 2022.10.5
Supervisor 2022.10.0
Operating System 9.2
Frontend 20221010.0 - latest
Shelly Plug 2 Firmware 20220809-124636/v1.12