Bug or error in my config? Disconnect from HA after switching Smartplug (Gosund SP112)

Hello!
I have a strange problem. My smartplug disconnects from the HA api every time I switch it. It is a Gosund SP112, this is my config. Some parts connected to the power measurement are commented out because otherwise the serial debug does not work. But the problem is independent of that.

substitutions:
  plug_name: esp_smartplug2
  plug_fullname: "Smartplug #2"
  comment: "Smartplug SP112 with USB ports and power measurement"
  # Variables for the power measurement
  # Lower value gives lower voltage readout
  voltage_factor: "1.89"

esphome:
  name: ${plug_name}
  platform: ESP8266
  board: esp8285
  # Save states in flash so that power outage does not cause total chaos afterwards, be careful: limited flash memory write cycles
  #esp8266_restore_from_flash: true

wifi:
  ssid: !secret wifissid
  password: !secret wifipassword
  # To change the address, set this to the old address, delete the #, flash, then put the # back and flash again
  #use_address: oldaddress.local
  ap:
    ssid: "$plug_name Fallback Hotspot"
    password: !secret otapassword

# Enable captive portal
captive_portal:

# Enable logging
logger:
  level: VERY_VERBOSE   #DEBUG is the default

# Enable Home Assistant API
api:
  password: !secret apipassword

# Enable OTA flashing
ota:
  safe_mode: True
  password: !secret otapassword

#Webserver
web_server:
  port: 80

# UART for the power sensor
#uart:
#  rx_pin: RX
#  baud_rate: 4800

# Send the firmware version to HA
text_sensor:
  - platform: version
    name: "$plug_fullname Firmware Version"

# Status LED, is inverted so it is normally of, blinks when error
status_led:
  pin:
    number: GPIO0
    inverted: True

# Send time to the plug, not used right now but could be useful for timed on/off
time:
  - platform: homeassistant
    id: my_time

binary_sensor:
  # Button changes virtual fakebutton state
  - platform: gpio
    id: button
    pin:
      number: GPIO16
      inverted: True
    on_multi_click:
    - timing:
      - ON for at most 1s
      - OFF for at most 1s
      - ON for at most 1s
      - OFF for at least 0.2s
      then:
        - logger.log: "Double Clicked"
        - switch.toggle: fakebuttonUSB
    - timing:
      - ON for 1s to 2s
      - OFF for at least 0.5s
      then:
        - logger.log: "Single Long Clicked"
        - switch.toggle: fakebutton
        - switch.toggle: fakebuttonUSB
    - timing:
      - ON for at most 1s
      - OFF for at least 0.5s
      then:
        - logger.log: "Single Short Clicked"
        - switch.toggle: fakebutton
  # Send status to HA
  - platform: status
    name: "$plug_fullname Status"

switch:
  # Virtual buttons
  - platform: template
    name: "$plug_fullname State"
    optimistic: true
    id: fakebutton
    turn_on_action:
    - switch.turn_on: relay
    - light.turn_on: led
    turn_off_action:
    - switch.turn_off: relay
    - light.turn_off: led
    restore_state: true
  - platform: template
    name: "$plug_fullname USB"
    optimistic: true
    id: fakebuttonUSB
    turn_on_action:
    - switch.turn_on: relayUSB
    - light.turn_on: led
    turn_off_action:
    - switch.turn_off: relayUSB
    - light.turn_off: led
    restore_state: true
  # Relays
  - platform: gpio
    id: relay
    pin: GPIO14
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    id: relayUSB
    pin: GPIO5
    restore_mode: RESTORE_DEFAULT_ON

output:
  # Blue LED to show relay on/off states
  - platform: esp8266_pwm
    id: pow_blue_led
    pin:
      number: GPIO2
      inverted: True

light:
  # Virtual light state
  - platform: monochromatic
    output: pow_blue_led
    id: led
    restore_mode: RESTORE_DEFAULT_OFF

sensor:
  #Send wifi signal strength
  - platform: wifi_signal
    name: "$plug_fullname WiFi Signal"
    update_interval: 60s
  # Send uptime
  - platform: uptime
    name: "$plug_fullname Uptime"
  # Power monitoring chip
#  - platform: cse7766
#    current:
#      name: "$plug_fullname Current"
#      unit_of_measurement: A
#    voltage:
#      name: "$plug_fullname Voltage"
#      unit_of_measurement: V
#      filters:
#        - multiply: $voltage_factor
#    power:
#      name: "$plug_fullname Power"
#      unit_of_measurement: W
#      id: power
#    update_interval: 5s
  # Total daily energy usage calculation
#  - platform: total_daily_energy
#    name: "$plug_fullname Total Daily Energy"
#    power_id: power
#    filters:
        # Multiplication factor from W to kW is 0.001
#        - multiply: 0.001
#    unit_of_measurement: kWh

This is the debug log:


INFO Reading configuration /config/esphome/esp_smartplug2.yaml...
INFO Detected timezone 'CET' with UTC offset 1 and daylight savings time from 29 March 02:00:00 to 25 October 03:00:00
INFO Starting log output from /dev/ttyUSB0 with baud rate 115200
[21:57:27]0
[21:57:27]ld
[21:57:27]
[21:57:27]SDK:2.2.1(cfd48f3)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
[21:57:27][I][logger:156]: Log initialized
[21:57:27][C][status_led:014]: Setting up Status LED...
[21:57:27][VV][preferences:038]: LOAD 32: valid=YES, 0=0x00000000 1=0x0DEFE4E3 (Type=233825507, CRC=0x0DEFE4E3)
[21:57:27][C][ota:364]: There have been 0 suspected unsuccessful boot attempts.
[21:57:27][VV][preferences:051]: SAVE 32: 0=0x00000001 1=0x42F4583F (Type=233825507, CRC=0x42F4583F)
[21:57:27][I][app:028]: Running through setup()...
[21:57:27][V][app:029]: Sorting components by setup priority...
[21:57:27][D][binary_sensor:034]: 'button': Sending initial state OFF
[21:57:27][VV][preferences:038]: LOAD 0: valid=YES, 0=0x00000000 1=0xCF427395 (Type=3477238677, CRC=0xCF427395)
[21:57:27][D][template.switch:050]:   Restored state OFF
[21:57:27][D][switch:025]: 'Smartplug #2 State' Turning OFF.
[21:57:27][D][switch:025]: 'relay' Turning OFF.
[21:57:27][D][switch:045]: 'relay': Sending state OFF
[21:57:27][D][light:264]: 'led' Setting:
[21:57:27][D][light:303]:   Transition Length: 1.0s
[21:57:27][VV][preferences:051]: SAVE 0: 0=0x00000000 1=0xCF427395 (Type=3477238677, CRC=0xCF427395)
[21:57:27][D][switch:045]: 'Smartplug #2 State': Sending state OFF
[21:57:27][VV][preferences:038]: LOAD 2: valid=NO, 0=0xFFFFFFFF 1=0xFFFFFFFF (Type=685782952, CRC=0x1804748B)
[21:57:27][C][switch.gpio:011]: Setting up GPIO Switch 'relay'...
[21:57:27][VV][preferences:038]: LOAD 4: valid=YES, 0=0x00000000 1=0xD3A92FE4 (Type=3551080420, CRC=0xD3A92FE4)
[21:57:27][D][switch:025]: 'relay' Turning OFF.
[21:57:27][D][switch:025]: 'relay' Turning OFF.
[21:57:27][C][switch.gpio:011]: Setting up GPIO Switch 'relayUSB'...
[21:57:27][VV][preferences:038]: LOAD 6: valid=YES, 0=0x00000001 1=0x470CCFC6 (Type=135754522, CRC=0x470CCFC6)
[21:57:27][D][switch:021]: 'relayUSB' Turning ON.
[21:57:27][VV][preferences:051]: SAVE 6: 0=0x00000001 1=0x470CCFC6 (Type=135754522, CRC=0x470CCFC6)
[21:57:27][D][switch:045]: 'relayUSB': Sending state ON
[21:57:27][D][switch:021]: 'relayUSB' Turning ON.
[21:57:27][C][esp8266_pwm:017]: Setting up ESP8266 PWM Output...
[21:57:27][VV][scheduler:056]: set_interval(name='update', interval=60000, offset=20094)
[21:57:27][C][light:097]: Setting up light 'led'...
[21:57:27][VV][preferences:038]: LOAD 8: valid=YES, 0=0x00000000 1=0x3F800000 (Type=646037088, CRC=0x2681BE60)
[21:57:27][D][light:264]: 'led' Setting:
[21:57:27][D][light:277]:   Brightness: 100%
[21:57:27][VV][preferences:051]: SAVE 8: 0=0x00000000 1=0x3F800000 (Type=646037088, CRC=0x2681BE60)
[21:57:27][D][binary_sensor:034]: 'Smartplug #2 Status': Sending initial state OFF
[21:57:27][D][text_sensor:015]: 'Smartplug #2 Firmware Version': Sending state '1.14.3 Jan  8 2020, 21:55:17'
[21:57:27][VV][scheduler:056]: set_interval(name='', interval=900000, offset=390586)
[21:57:27][VV][preferences:038]: LOAD 17: valid=NO, 0=0x00000000 1=0xA0BC17C1 (Type=2051358253, CRC=0x696E4CB2)
[21:57:27][C][wifi:033]: Setting up WiFi...
[21:57:27][V][wifi_esp8266:043]: Disabling AP.
[21:57:27]bcn 0
[21:57:27]del if1
[21:57:27]usl
[21:57:27]mode : null
[21:57:27][V][wifi_esp8266:033]: Enabling STA.
[21:57:27]mode : sta(dc:4f:22:9c:b0:81)
[21:57:27]add if0
[21:57:27][V][wifi_esp8266:376]: Event: Changed Mode old=AP new=OFF
[21:57:27]wifi evt: 8
[21:57:27][V][wifi_esp8266:376]: Event: Changed Mode old=OFF new=STA
[21:57:27]wifi evt: 8
[21:57:27]sleep disable
[21:57:27][D][wifi:304]: Starting scan...
[21:57:27][VV][scheduler:131]: Running interval '' with interval=900000 last_execution=4293690714 (now=14060)
[21:57:27][VV][scheduler:131]: Running interval 'update' with interval=60000 last_execution=4294901148 (now=14060)
[21:57:27][V][sensor:013]: 'Smartplug #2 Uptime': Received new state 14.076000
[21:57:27][D][sensor:092]: 'Smartplug #2 Uptime': Sending state 14.07600 s with 0 decimals of accuracy
[21:57:33]scandone
[21:57:33][D][wifi:319]: Found networks:
[21:57:33][I][wifi:365]: - 'MyWIFI' 

[redacted]▂▄▆█
[21:57:33][D][wifi:366]:     Channel: 11
[21:57:33][D][wifi:367]:     RSSI: -47 dB
[21:57:33][I][wifi:365]: - 'MyWIFI' 

[redacted]▂▄▆█

[21:57:33][I][wifi:193]: WiFi Connecting to 'MyWIFI'...
[21:57:33][V][wifi:195]: Connection Params:
[21:57:33][V][wifi:196]:   SSID: 'MyWIFI'
[21:57:33][V][wifi:199]:   BSSID: 04:F0:21:23:31:0F
[21:57:33][V][wifi:203]:   Password: 

[redacted]
[21:57:33][V][wifi:205]:   Channel: 11
[21:57:33][V][wifi:215]:   Using DHCP IP
[21:57:33][V][wifi:217]:   Hidden: NO
[21:57:33][V][wifi_esp8266:344]: Event: Changed AuthMode old=OPEN new=WPA2 PSK
[21:57:33]wifi evt: 2
[21:57:34]scandone
[21:57:35]state: 0 -> 2 (b0)
[21:57:35]state: 2 -> 3 (0)
[21:57:35]state: 3 -> 5 (10)
[21:57:35]add 0
[21:57:35]aid 10
[21:57:35]cnt 
[21:57:35]
[21:57:35]connected with MyWIFI, channel 11
[21:57:35]dhcp client start...
[21:57:35][V][wifi_esp8266:325]: Event: Connected ssid='MyWIFI' bssid=04:F0:21:23:31:0F channel=11
[21:57:35]wifi evt: 0
[21:57:35]ip:192.168.0.249,mask:255.255.255.0,gw:192.168.0.1
[21:57:35][V][wifi_esp8266:350]: Event: Got IP static_ip=192.168.0.249 gateway=192.168.0.1 netmask=255.255.255.0
[21:57:35]wifi evt: 3
[21:57:35][I][wifi:423]: WiFi Connected!
[21:57:35][C][wifi:283]:   SSID: 

[redacted]
[21:57:35][C][wifi:284]:   IP Address: 192.168.0.249
[21:57:35][C][wifi:286]:   BSSID: 

[redacted]
[21:57:35][C][wifi:287]:   Hostname: 'esp_smartplug2'
[21:57:35][C][wifi:291]:   Signal strength: -56 dB ▂▄▆█
[21:57:35][V][wifi:293]:   Priority: 0.0
[21:57:35][C][wifi:295]:   Channel: 11
[21:57:35][C][wifi:296]:   Subnet: 255.255.255.0
[21:57:35][C][wifi:297]:   Gateway: 192.168.0.1
[21:57:35][C][wifi:298]:   DNS1: 192.168.0.1
[21:57:35][C][wifi:299]:   DNS2: (IP unset)
[21:57:35][D][wifi:432]: Disabling AP...
[21:57:35][C][web_server:066]: Setting up web server...
[21:57:35][VV][scheduler:056]: set_interval(name='', interval=10000, offset=4454)
[21:57:35][C][ota:029]: Over-The-Air Updates:
[21:57:35][C][ota:030]:   Address: esp_smartplug2.local:8266
[21:57:35][C][ota:032]:   Using Password.
[21:57:35][C][api:022]: Setting up Home Assistant API server...
[21:57:35][VV][scheduler:056]: set_interval(name='update', interval=60000, offset=29199)
[21:57:35][I][app:058]: setup() finished successfully!
[21:57:35][VV][scheduler:131]: Running interval 'update' with interval=60000 last_execution=4294899885 (now=21794)
[21:57:35][V][sensor:013]: 'Smartplug #2 WiFi Signal': Received new state -56.000000
[21:57:35][D][sensor:092]: 'Smartplug #2 WiFi Signal': Sending state -56.00000 dB with 0 decimals of accuracy
[21:57:35][VV][scheduler:131]: Running interval '' with interval=10000 last_execution=7305 (now=21794)
[21:57:35][I][app:100]: ESPHome version 1.14.3 compiled on Jan  8 2020, 21:55:17
[21:57:35][C][status_led:019]: Status LED:
[21:57:35][C][status_led:020]:   Pin: GPIO0 (Mode: OUTPUT, INVERTED)
[21:57:35][C][wifi:415]: WiFi:
[21:57:35][C][wifi:283]:   SSID: 

[redacted]
[21:57:35][C][wifi:284]:   IP Address: 192.168.0.249
[21:57:35][C][wifi:286]:   BSSID: 

[redacted]
[21:57:35][C][wifi:287]:   Hostname: 'esp_smartplug2'
[21:57:35][C][wifi:291]:   Signal strength: -56 dB ▂▄▆█
[21:57:35][V][wifi:293]:   Priority: 0.0
[21:57:35][C][wifi:295]:   Channel: 11
[21:57:35][C][wifi:296]:   Subnet: 255.255.255.0
[21:57:35][C][wifi:297]:   Gateway: 192.168.0.1
[21:57:35][C][wifi:298]:   DNS1: 192.168.0.1
[21:57:35][C][wifi:299]:   DNS2: (IP unset)
[21:57:35][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'button'
[21:57:35][C][gpio.binary_sensor:016]:   Pin: GPIO16 (Mode: INPUT, INVERTED)
[21:57:35][C][template.switch:058]: Template Switch 'Smartplug #2 State'
[21:57:35][C][template.switch:059]:   Restore State: YES
[21:57:35][C][template.switch:060]:   Optimistic: YES
[21:57:35][C][template.switch:058]: Template Switch 'Smartplug #2 USB'
[21:57:35][C][template.switch:059]:   Restore State: YES
[21:57:35][C][template.switch:060]:   Optimistic: YES
[21:57:35][C][switch.gpio:042]: GPIO Switch 'relay'
[21:57:35][C][switch.gpio:043]:   Pin: GPIO14 (Mode: OUTPUT)
[21:57:35][C][switch.gpio:059]:   Restore Mode: Restore (Defaults to OFF)
[21:57:35][C][switch.gpio:042]: GPIO Switch 'relayUSB'
[21:57:35][C][switch.gpio:043]:   Pin: GPIO5 (Mode: OUTPUT)
[21:57:35][C][switch.gpio:059]:   Restore Mode: Restore (Defaults to ON)
[21:57:35][C][esp8266_pwm:022]: ESP8266 PWM:
[21:57:35][C][esp8266_pwm:023]:   Pin: GPIO2 (Mode: OUTPUT, INVERTED)
[21:57:35][C][esp8266_pwm:024]:   Frequency: 1000.0 Hz
[21:57:35][C][uptime.sensor:030]: Uptime Sensor 'Smartplug #2 Uptime'
[21:57:35][C][uptime.sensor:030]:   Unit of Measurement: 's'
[21:57:35][C][uptime.sensor:030]:   Accuracy Decimals: 0
[21:57:35][C][uptime.sensor:030]:   Icon: 'mdi:timer'
[21:57:35][V][uptime.sensor:030]:   Unique ID: 'dc4f229cb081-uptime'
[21:57:35][C][logger:175]: Logger:
[21:57:35][C][logger:176]:   Level: VERY_VERBOSE
[21:57:35][C][logger:177]:   Log Baud Rate: 115200
[21:57:35][C][logger:178]:   Hardware UART: UART0
[21:57:35][C][light:177]: Light 'led'
[21:57:35][C][light:179]:   Default Transition Length: 1.0s
[21:57:35][C][light:180]:   Gamma Correct: 2.80
[21:57:35][C][status:034]: Status Binary Sensor 'Smartplug #2 Status'
[21:57:35][C][status:034]:   Device Class: 'connectivity'
[21:57:35][C][version.text_sensor:015]: Version Text Sensor 'Smartplug #2 Firmware Version'
[21:57:35][C][version.text_sensor:015]:   Icon: 'mdi:new-box'
[21:57:35][V][version.text_sensor:015]:   Unique ID: 'dc4f229cb081-version'
[21:57:35][C][homeassistant.time:010]: Home Assistant Time:
[21:57:35][C][homeassistant.time:011]:   Timezone: 'CET-1CEST-2,M3.5.0/2,M10.4.0/3'
[21:57:35][C][captive_portal:169]: Captive Portal:
[21:57:35][C][web_server:122]: Web Server:
[21:57:35][C][web_server:123]:   Address: esp_smartplug2.local:80
[21:57:35][C][ota:029]: Over-The-Air Updates:
[21:57:35][C][ota:030]:   Address: esp_smartplug2.local:8266
[21:57:35][C][ota:032]:   Using Password.
[21:57:35][C][api:095]: API Server:
[21:57:35][C][api:096]:   Address: esp_smartplug2.local:6053
[21:57:35][C][wifi_signal.sensor:009]: WiFi Signal 'Smartplug #2 WiFi Signal'
[21:57:35][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[21:57:35][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[21:57:36][C][wifi_signal.sensor:009]:   Icon: 'mdi:wifi'
[21:57:36][V][wifi_signal.sensor:009]:   Unique ID: 'dc4f229cb081-wifisignal'
[21:57:40][VV][scheduler:131]: Running interval '' with interval=10000 last_execution=17305 (now=27310)
[21:57:45]pm open,type:0 0
[21:57:50][D][binary_sensor:036]: 'Smartplug #2 Status': Sending state ON
[21:57:50][VV][api.service:222]: on_hello_request: HelloRequest {
[21:57:50]  client_info: 'Home Assistant 0.103.5'
[21:57:50]}
[21:57:50][V][api.connection:567]: Hello from client: 'Home Assistant 0.103.5 (192.168.0.33)'
[21:57:50][VV][api.service:010]: send_hello_response: HelloResponse {
[21:57:50]  api_version_major: 1
[21:57:50]  api_version_minor: 3
[21:57:50]  server_info: 'esp_smartplug2 (esphome v1.14.3)'
[21:57:50]}
[21:57:50][VV][api.service:229]: on_connect_request: ConnectRequest {
[21:57:50]  password: 'redacted'
[21:57:50]}
[21:57:50][D][api.connection:583]: Client 'Home Assistant 0.103.5 (192.168.0.33)' connected successfully!
[21:57:50][VV][api.service:171]: send_get_time_request: GetTimeRequest {}
[21:57:50][VV][api.service:015]: send_connect_response: ConnectResponse {
[21:57:50]  invalid_password: NO
[21:57:50]}
[21:57:50][VV][api.service:342]: on_get_time_response: GetTimeResponse {
[21:57:50]  epoch_seconds: 1578517070
[21:57:50]}
[21:57:50][D][time:029]: Synchronized time: Wed Jan  8 21:57:50 2020
[21:57:50][VV][api.service:264]: on_device_info_request: DeviceInfoRequest {}
[21:57:50][VV][api.service:040]: send_device_info_response: DeviceInfoResponse {
[21:57:50]  uses_password: YES
[21:57:50]  name: 'esp_smartplug2'
[21:57:50]  mac_address: 'DC:4F:22:9C:B0:81'
[21:57:50]  esphome_version: '1.14.3'
[21:57:50]  compilation_time: 'Jan  8 2020, 21:55:17'
[21:57:50]  model: 'PLATFORMIO_ESP8285'
[21:57:50]  has_deep_sleep: NO
[21:57:50]}
[21:57:50][VV][api.service:271]: on_list_entities_request: ListEntitiesRequest {}
[21:57:50][VV][api.service:051]: send_list_entities_binary_sensor_response: ListEntitiesBinarySensorResponse {
[21:57:50]  object_id: 'smartplug_2_status'
[21:57:50]  key: 3399211564
[21:57:50]  name: 'Smartplug #2 Status'
[21:57:50]  unique_id: 'esp_smartplug2binary_sensorsmartplug_2_status'
[21:57:50]  device_class: 'connectivity'
[21:57:50]  is_status_binary_sensor: YES
[21:57:50]}
[21:57:50][VV][api.service:113]: send_list_entities_sensor_response: ListEntitiesSensorResponse {
[21:57:50]  object_id: 'smartplug_2_wifi_signal'
[21:57:50]  key: 3552917572
[21:57:50]  name: 'Smartplug #2 WiFi Signal'
[21:57:50]  unique_id: 'dc4f229cb081-wifisignal'
[21:57:50]  icon: 'mdi:wifi'
[21:57:50]  unit_of_measurement: 'dB'
[21:57:50]  accuracy_decimals: 0
[21:57:50]  force_update: NO
[21:57:50]}
[21:57:50][VV][api.service:113]: send_list_entities_sensor_response: ListEntitiesSensorResponse {
[21:57:50]  object_id: 'smartplug_2_uptime'
[21:57:50]  key: 80662530
[21:57:50]  name: 'Smartplug #2 Uptime'
[21:57:50]  unique_id: 'dc4f229cb081-uptime'
[21:57:50]  icon: 'mdi:timer'
[21:57:50]  unit_of_measurement: 's'
[21:57:50]  accuracy_decimals: 0
[21:57:50]  force_update: NO
[21:57:50]}
[21:57:50][VV][scheduler:131]: Running interval '' with interval=10000 last_execution=27305 (now=37364)
[21:57:50][VV][api.service:127]: send_list_entities_switch_response: ListEntitiesSwitchResponse {
[21:57:50]  object_id: 'smartplug_2_state'
[21:57:50]  key: 3477238677
[21:57:50]  name: 'Smartplug #2 State'
[21:57:50]  unique_id: 'esp_smartplug2switchsmartplug_2_state'
[21:57:50]  icon: ''
[21:57:50]  assumed_state: NO
[21:57:50]}
[21:57:50][VV][api.service:127]: send_list_entities_switch_response: ListEntitiesSwitchResponse {
[21:57:50]  object_id: 'smartplug_2_usb'
[21:57:50]  key: 685782952
[21:57:50]  name: 'Smartplug #2 USB'
[21:57:50]  unique_id: 'esp_smartplug2switchsmartplug_2_usb'
[21:57:50]  icon: ''
[21:57:50]  assumed_state: NO
[21:57:50]}
[21:57:51][VV][api.service:143]: send_list_entities_text_sensor_response: ListEntitiesTextSensorResponse {
[21:57:51]  object_id: 'smartplug_2_firmware_version'
[21:57:51]  key: 2344351488
[21:57:51]  name: 'Smartplug #2 Firmware Version'
[21:57:51]  unique_id: 'dc4f229cb081-version'
[21:57:51]  icon: 'mdi:new-box'
[21:57:51]}
[21:57:51][VV][api.service:045]: send_list_entities_done_response: ListEntitiesDoneResponse {}
[21:57:51][VV][api.service:278]: on_subscribe_states_request: SubscribeStatesRequest {}
[21:57:51][VV][api.service:328]: on_subscribe_homeassistant_services_request: SubscribeHomeassistantServicesRequest {}
[21:57:51][VV][api.service:349]: on_subscribe_home_assistant_states_request: SubscribeHomeAssistantStatesRequest {}
[21:57:51][VV][api.service:058]: send_binary_sensor_state_response: BinarySensorStateResponse {
[21:57:51]  key: 3399211564
[21:57:51]  state: YES
[21:57:51]  missing_state: NO
[21:57:51]}
[21:57:51][VV][api.service:120]: send_sensor_state_response: SensorStateResponse {
[21:57:51]  key: 3552917572
[21:57:51]  state: -56
[21:57:51]  missing_state: NO
[21:57:51]}
[21:57:51][VV][api.service:120]: send_sensor_state_response: SensorStateResponse {
[21:57:51]  key: 80662530
[21:57:51]  state: 14.076
[21:57:51]  missing_state: NO
[21:57:51]}
[21:57:51][VV][api.service:134]: send_switch_state_response: SwitchStateResponse {
[21:57:51]  key: 3477238677
[21:57:51]  state: NO
[21:57:51]}
[21:57:51][VV][api.service:134]: send_switch_state_response: SwitchStateResponse {
[21:57:51]  key: 685782952
[21:57:51]  state: NO
[21:57:51]}
[21:57:51][VV][api.service:150]: send_text_sensor_state_response: TextSensorStateResponse {
[21:57:51]  key: 2344351488
[21:57:51]  state: '1.14.3 Jan  8 2020, 21:55:17'
[21:57:51]  missing_state: NO
[21:57:51]}
[21:58:00][VV][scheduler:131]: Running interval '' with interval=10000 last_execution=37305 (now=47305)
[21:58:05][VV][api.service:250]: on_ping_request: PingRequest {}
[21:58:05][VV][api.service:035]: send_ping_response: PingResponse {}
[21:58:06][VV][scheduler:131]: Running interval 'update' with interval=60000 last_execution=4294959885 (now=52590)
[21:58:06][V][sensor:013]: 'Smartplug #2 WiFi Signal': Received new state -56.000000
[21:58:06][D][sensor:092]: 'Smartplug #2 WiFi Signal': Sending state -56.00000 dB with 0 decimals of accuracy
[21:58:06][VV][api.service:120]: send_sensor_state_response: SensorStateResponse {
[21:58:06]  key: 3552917572
[21:58:06]  state: -56
[21:58:06]  missing_state: NO
[21:58:06]}
[21:58:07][VV][scheduler:131]: Running interval 'update' with interval=60000 last_execution=4294961148 (now=53858)
[21:58:07][V][sensor:013]: 'Smartplug #2 Uptime': Received new state 53.862000
[21:58:07][D][sensor:092]: 'Smartplug #2 Uptime': Sending state 53.86200 s with 0 decimals of accuracy
[21:58:07][VV][api.service:120]: send_sensor_state_response: SensorStateResponse {
[21:58:07]  key: 80662530
[21:58:07]  state: 53.862
[21:58:07]  missing_state: NO
[21:58:07]}
[21:58:10][VV][scheduler:131]: Running interval '' with interval=10000 last_execution=47305 (now=57305)
[21:58:14][VV][api.service:320]: on_switch_command_request: SwitchCommandRequest {
[21:58:14]  key: 3477238677
[21:58:14]  state: YES
[21:58:14]}
[21:58:14][D][switch:021]: 'Smartplug #2 State' Turning ON.
[21:58:14][D][switch:021]: 'relay' Turning ON.
[21:58:14][VV][preferences:107]: Saving preferences to flash...
[21:58:19][VV][preferences:051]: SAVE 4: 0=0x00000001 1=0x9CB29338 (Type=3551080420, CRC=0x9CB29338)
[21:58:19][D][switch:045]: 'relay': Sending state ON
[21:58:19][D][light:264]: 'led' Setting:
[21:58:19][D][light:273]:   State: ON
[21:58:19][D][light:303]:   Transition Length: 1.0s
[21:58:20][VV][preferences:107]: Saving preferences to flash...
[21:58:25][VV][preferences:051]: SAVE 8: 0=0x00000001 1=0x3F800000 (Type=646037088, CRC=0x699A02BC)
[21:58:25][VV][preferences:107]: Saving preferences to flash...
[21:58:30][VV][preferences:051]: SAVE 0: 0=0x00000001 1=0x8059CF49 (Type=3477238677, CRC=0x8059CF49)
[21:58:30][D][switch:045]: 'Smartplug #2 State': Sending state ON
[21:58:30][VV][api.service:134]: send_switch_state_response: SwitchStateResponse {
[21:58:30]  key: 3477238677
[21:58:30]  state: YES
[21:58:30]}
[21:58:30][V][app:076]: A component took a long time in a loop() cycle (16.39 s).
[21:58:30][V][app:077]: Components should block for at most 20-30ms in loop().
[21:58:30][VV][scheduler:131]: Running interval '' with interval=10000 last_execution=57305 (now=77352)
[21:58:30][D][api:067]: Disconnecting Home Assistant 0.103.5 (192.168.0.33)
[21:58:30][D][binary_sensor:036]: 'Smartplug #2 Status': Sending state OFF
[21:58:40][D][binary_sensor:036]: 'Smartplug #2 Status': Sending state ON
[21:58:40][VV][api.service:222]: on_hello_request: HelloRequest {
[21:58:40]  client_info: 'Home Assistant 0.103.5'
[21:58:40]}
[21:58:40][V][api.connection:567]: Hello from client: 'Home Assistant 0.103.5 (192.168.0.33)'
[21:58:40][VV][api.service:010]: send_hello_response: HelloResponse {
etc. etc.

Look at this for example, while this happesn HA looses the api connection.

[21:58:30][V][app:076]: A component took a long time in a loop() cycle (16.39 s).
[21:58:30][V][app:077]: Components should block for at most 20-30ms in loop().

Why does this happen? I’m extremely sure that this worked with the exact config a few versions and weeks ago.

Thank you for your great work otherwise! Cheers, James

Does anyone have an idea? Maybe I should try on github issues?