Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API disconnect and potential ESP32 crash while sending Stage, Sub Mode, and Auto Sub Mode info. #215

Closed
drew-hill opened this issue Jan 6, 2025 · 4 comments

Comments

@drew-hill
Copy link

drew-hill commented Jan 6, 2025

Issue Summary
Device launches, successfully reads items through Stage, Sub Mode, and Auto Mode Sub Mode (~ process step 5b), then hangs and loses connection. This repeats about once or twice before what appears to be a full on ESP32 crash.

Similar behavior may occurr slightly earlier in the process (during 5a attempts to write a packet). I wonder if the issue might be related to writing a packet with Stage, Sub Mode, or Auto Sub Mode related content.

There was a recent commit (106a2d3) and related request (aa9f5a7) that time up well with my issue, but this may be more superstitious than anything.

Brief Example 1 (Stage and Sub Mode info)

[16:28:58][D][Decoder:155]: [Stage : GENTLE]
[16:28:58][D][Decoder:156]: [Sub Mode  : NORMAL]
[16:28:58][D][Decoder:157]: [Auto Mode Sub Mode  : AUTO_OFF]
[16:28:58][D][text_sensor:064]: 'Stage': Sending state 'GENTLE'
WARNING <Hostname> @ <My IP Address>: Connection error occurred: [Errno 54] Connection reset by peer

Brief Example 2 (packet writing)

[16:22:12][D][CYCLE:352]: 5a: Sending power request (0x09)
[16:22:12][D][CN105:323]: creating Info packet
[16:22:12][D][CN105:084]: writing packet...
WARNING <Hostname> @ <My IP Address>: Connection error occurred: [Errno 54] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for <Hostname> @ <My IP Address>
WARNING Disconnected from API
WARNING Can't connect to ESPHome API for <Hostname> @ <My IP Address>: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='10`

Extended Example

INFO Successfully uploaded program.
INFO Starting log output from <Hostname>.local using esphome API
INFO Successfully connected to <Hostname> @ <My IP Address> in 8.104s
INFO Successful handshake with <Hostname> @ <My IP Address> in 0.023s
[16:20:45][I][app:100]: ESPHome version 2024.12.2 compiled on Jan  5 2025, 16:19:16
[16:20:45][C][wifi:600]: WiFi:
[16:20:45][C][wifi:428]:   Local MAC:<MAC>
[16:20:45][C][wifi:433]:   SSID: '<SSID>'
[16:20:45][C][wifi:436]:   IP Address: <My IP Address>
[16:20:45][C][wifi:439]:   BSSID: <BSSID>
[16:20:45][C][wifi:441]:   Hostname: '<Hostname>'
[16:20:45][C][wifi:443]:   Signal strength: -36 dB ▂▄▆█
[16:20:45][C][wifi:447]:   Channel: 11
[16:20:45][C][wifi:448]:   Subnet: <Subnet>
[16:20:45][C][wifi:449]:   Gateway: <Router IP Address>
[16:20:45][C][wifi:450]:   DNS1: <Router IP Address>
[16:20:45][C][wifi:451]:   DNS2: 0.0.0.0
[16:20:45][D][CN105:308]: sending a request for settings packet (0x02)
[16:20:45][I][CYCLE:039]: 1: Cycle start
[16:20:45][D][CYCLE:311]: 2a: Sending settings request (0x02)
[16:20:45][C][version.text_sensor:021]: Version Text Sensor 'ESPHome Version'
[16:20:45][C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[16:20:45][C][restart.button:017]: Restart Button 'Restart ESPHome Heatpump'
[16:20:45][C][restart.button:017]:   Icon: 'mdi:restart'
[16:20:45][C][captive_portal:089]: Captive Portal:
[16:20:45][C][web_server:153]: Web Server:
[16:20:45][C][web_server:154]:   Address: <Hostname>.local:80
[16:20:45][C][mdns:116]: mDNS:
[16:20:45][C][mdns:117]:   Hostname: <Hostname>
[16:20:46][C][esphome.ota:073]: Over-The-Air updates:
[16:20:46][C][esphome.ota:074]:   Address: <Hostname>.local:3232
[16:20:46][C][esphome.ota:075]:   Version: 2
[16:20:46][C][safe_mode:018]: Safe Mode:
[16:20:46][C][safe_mode:019]:   Boot considered successful after 60 seconds
[16:20:46][C][safe_mode:021]:   Invoke after 10 boot attempts
[16:20:46][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[16:20:46][C][api:140]: API Server:
[16:20:46][C][api:141]:   Address: <Hostname>.local:6053
[16:20:46][C][api:145]:   Using noise encryption: NO
[16:20:46][C][wifi_info:012]: WifiInfo SSID 'SSID'
[16:20:46][C][wifi_info:013]: WifiInfo BSSID 'BSSID'
[16:20:46][C][wifi_info:010]: WifiInfo IPAddress 'IP'
[16:20:46][C][wifi_signal.sensor:010]: WiFi Signal 'WiFi Signal'
[16:20:46][C][wifi_signal.sensor:010]:   Device Class: 'signal_strength'
[16:20:46][C][wifi_signal.sensor:010]:   State Class: 'measurement'
[16:20:46][C][wifi_signal.sensor:010]:   Unit of Measurement: 'dBm'
[16:20:46][C][wifi_signal.sensor:010]:   Accuracy Decimals: 0
[16:20:46][D][CYCLE:318]: 2b: Receiving settings response
[16:20:46][D][Decoder:176]: [0x02 is settings]
[16:20:46][D][Decoder:184]: [Power : ON]
[16:20:46][D][Decoder:185]: [iSee  : 0]
[16:20:46][D][Decoder:186]: [Mode  : HEAT]
[16:20:46][D][CN105:268]: Climate action is: 4
[16:20:46][I][CN105:620]: fan setting changed
[16:20:46][D][CN105:639]: Fan mode is: 2
[16:20:46][I][SETTINGS:529]: vane setting changed
[16:20:46][D][SETTINGS:551]: Swing mode is: 0
[16:20:46][I][CN105:566]: widevane setting changed
[16:20:46][D][SETTINGS:103]: [settings]-> [power: ON, target °C: 21.0, mode: HEAT, fan: AUTO, vane: AUTO, wvane: ←←]
[16:20:46][D][CN105:587]: Swing mode is: 0
[16:20:46][D][CYCLE:321]: 3a: Sending room °C request (0x03)
[16:20:46][D][CN105:323]: creating Info packet
[16:20:46][D][CN105:084]: writing packet...
[16:20:46][D][CYCLE:327]: 3b: Receiving room °C response
[16:20:46][D][Decoder:256]: [Room °C: 20.000000]
[16:20:46][D][Decoder:257]: [OAT  °C: 9.000000]
[16:20:46][I][STATUS:128]: [received]-> [room C°: 20.0, operating: NO , compressor freq: nan Hz]
[16:20:46][I][STATUS:128]: [current]-> [room C°: 0.0, operating: NO , compressor freq: nan Hz]
[16:20:46][D][CN105:218]: setting action to -> 4
[16:20:46][D][CN105:267]: Climate mode is: 3
[16:20:46][D][CN105:268]: Climate action is: 4
[16:20:46][D][CYCLE:330]: 4a: Sending status request (0x06)
[16:20:46][D][CN105:323]: creating Info packet
[16:20:46][D][CN105:084]: writing packet...
[16:20:46][D][CYCLE:348]: 4b: Receiving status response
[16:20:46][D][Decoder:280]: [0x06 is status]
[16:20:46][I][STATUS:128]: [received]-> [room C°: 20.0, operating: YES, compressor freq: 24.0 Hz]
[16:20:46][I][STATUS:128]: [current]-> [room C°: 20.0, operating: NO , compressor freq: nan Hz]
[16:20:46][D][CN105:218]: setting action to -> 3
[16:20:46][D][CN105:267]: Climate mode is: 3
[16:20:46][D][CN105:268]: Climate action is: 3
[16:20:46][D][CYCLE:352]: 5a: Sending power request (0x09)
[16:20:46][D][CN105:323]: creating Info packet
[16:20:46][D][CN105:084]: writing packet...
[16:20:47][D][CYCLE:367]: 5b: Receiving Power/Standby response
[16:20:47][D][Decoder:148]: [0x09 is sub modes]
[16:20:47][D][Decoder:155]: [Stage : GENTLE]
[16:20:47][D][Decoder:156]: [Sub Mode  : NORMAL]
[16:20:47][D][Decoder:157]: [Auto Mode Sub Mode  : AUTO_OFF]
[16:20:47][D][text_sensor:064]: 'Stage': Sending state 'GENTLE'
[16:20:47][D][text_sensor:064]: 'Sub Mode': Sending state 'NORMAL'
WARNING <Hostname> @ <My IP Address>: Connection error occurred: [Errno 54] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for <Hostname> @ <My IP Address>
WARNING Disconnected from API
INFO Successfully connected to <Hostname> @ <My IP Address> in 0.157s
INFO Successful handshake with <Hostname> @ <My IP Address> in 0.031s
[16:21:28][D][CN105:308]: sending a request for settings packet (0x02)
[16:21:28][I][CYCLE:039]: 1: Cycle start
[16:21:28][D][CYCLE:311]: 2a: Sending settings request (0x02)
[16:21:28][D][CN105:323]: creating Info packet
[16:21:28][D][CN105:084]: writing packet...
[16:21:28][D][CYCLE:318]: 2b: Receiving settings response
[16:21:28][D][Decoder:176]: [0x02 is settings]
[16:21:28][D][Decoder:184]: [Power : ON]
[16:21:28][D][Decoder:185]: [iSee  : 0]
[16:21:28][D][Decoder:186]: [Mode  : HEAT]
[16:21:28][D][Decoder:198]: [Temp °C: 21.000000]
[16:21:28][D][Decoder:201]: [Fan: AUTO]
[16:21:28][D][Decoder:204]: [Vane: AUTO]
[16:21:28][W][lookup:204]: wideVane reading caution: value 0 not found, returning value at index 0
[16:21:28][D][Decoder:209]: [wideVane: ←← (adj:0)]
[16:21:28][D][SETTINGS:103]: [current]-> [power: -, target °C: -1.0, mode: -, fan: -, vane: -, wvane: -]
[16:21:28][D][SETTINGS:103]: [received]-> [power: ON, target °C: 21.0, mode: HEAT, fan: AUTO, vane: AUTO, wvane: ←←]
[16:21:28][D][EVT_SETS:060]: [wanted]-> [power: -, target °C: -1.0, mode: -, fan: -, vane: -, wvane: -, hasChanged ? ->  NO, hasBeenSent ? ->  NO]
[16:21:28][D][SETTINGS:087]: [climate]-> [mode: OFF, target °C: nan, fan: OFF, swing: OFF]
[16:21:28][D][SETTINGS:522]: Settings changed, updating HA states
[16:21:28][I][CN105:650]: power or mode changed
[16:21:28][D][CN105:218]: setting action to -> 4
[16:21:28][D][CN105:267]: Climate mode is: 3
[16:21:28][D][CN105:268]: Climate action is: 4
[16:21:28][I][CN105:620]: fan setting changed
[16:21:28][D][CN105:639]: Fan mode is: 2
[16:21:28][I][SETTINGS:529]: vane setting changed
[16:21:28][D][SETTINGS:551]: Swing mode is: 0
[16:21:28][I][CN105:566]: widevane setting changed
[16:21:28][D][SETTINGS:103]: [settings]-> [power: ON, target °C: 21.0, mode: HEAT, fan: AUTO, vane: AUTO, wvane: ←←]
[16:21:28][D][CN105:587]: Swing mode is: 0
[16:21:28][D][CYCLE:321]: 3a: Sending room °C request (0x03)
[16:21:28][D][CN105:323]: creating Info packet
[16:21:29][D][CYCLE:327]: 3b: Receiving room °C response
[16:21:29][D][Decoder:256]: [Room °C: 20.000000]
[16:21:29][D][Decoder:257]: [OAT  °C: 9.000000]
[16:21:29][I][STATUS:128]: [received]-> [room C°: 20.0, operating: NO , compressor freq: nan Hz]
[16:21:29][I][STATUS:128]: [current]-> [room C°: 0.0, operating: NO , compressor freq: nan Hz]
[16:21:29][D][CN105:218]: setting action to -> 4
[16:21:29][D][CN105:267]: Climate mode is: 3
[16:21:29][D][CN105:268]: Climate action is: 4
[16:21:29][D][CYCLE:330]: 4a: Sending status request (0x06)
[16:21:29][D][CN105:323]: creating Info packet
[16:21:29][D][CN105:084]: writing packet...
[16:21:29][D][CYCLE:348]: 4b: Receiving status response
[16:21:29][D][Decoder:280]: [0x06 is status]
[16:21:29][I][STATUS:128]: [received]-> [room C°: 20.0, operating: YES, compressor freq: 24.0 Hz]
[16:21:29][I][STATUS:128]: [current]-> [room C°: 20.0, operating: NO , compressor freq: nan Hz]
[16:21:29][D][CN105:218]: setting action to -> 3
[16:21:29][D][CN105:267]: Climate mode is: 3
[16:21:29][D][CN105:268]: Climate action is: 3
[16:21:29][D][CYCLE:352]: 5a: Sending power request (0x09)
[16:21:29][D][CN105:323]: creating Info packet
[16:21:29][D][CN105:084]: writing packet...
[16:21:29][D][CYCLE:367]: 5b: Receiving Power/Standby response
[16:21:29][D][Decoder:148]: [0x09 is sub modes]
[16:21:29][D][Decoder:155]: [Stage : GENTLE]
[16:21:29][D][Decoder:156]: [Sub Mode  : NORMAL]
WARNING <Hostname> @ <My IP Address>: Connection error occurred: [Errno 54] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for <Hostname> @ <My IP Address>
WARNING Disconnected from API
INFO Successfully connected to <Hostname> @ <My IP Address> in 1.164s
INFO Successful handshake with <Hostname> @ <My IP Address> in 0.029s
[16:22:11][D][CN105:308]: sending a request for settings packet (0x02)
[16:22:11][I][CYCLE:039]: 1: Cycle start
[16:22:11][D][CYCLE:311]: 2a: Sending settings request (0x02)
[16:22:11][D][CN105:323]: creating Info packet
[16:22:11][D][CN105:084]: writing packet...
[16:22:11][D][CYCLE:318]: 2b: Receiving settings response
[16:22:11][D][Decoder:176]: [0x02 is settings]
[16:22:11][D][Decoder:184]: [Power : ON]
[16:22:11][D][Decoder:185]: [iSee  : 0]
[16:22:11][D][Decoder:186]: [Mode  : HEAT]
[16:22:11][D][Decoder:198]: [Temp °C: 21.000000]
[16:22:11][D][Decoder:201]: [Fan: AUTO]
[16:22:11][D][Decoder:204]: [Vane: AUTO]
[16:22:11][W][lookup:204]: wideVane reading caution: value 0 not found, returning value at index 0
[16:22:11][D][Decoder:209]: [wideVane: ←← (adj:0)]
[16:22:11][D][SETTINGS:103]: [current]-> [power: -, target °C: -1.0, mode: -, fan: -, vane: -, wvane: -]
[16:22:11][D][SETTINGS:103]: [received]-> [power: ON, target °C: 21.0, mode: HEAT, fan: AUTO, vane: AUTO, wvane: ←←]
[16:22:11][D][EVT_SETS:060]: [wanted]-> [power: -, target °C: -1.0, mode: -, fan: -, vane: -, wvane: -, hasChanged ? ->  NO, hasBeenSent ? ->  NO]
[16:22:11][D][SETTINGS:087]: [climate]-> [mode: OFF, target °C: nan, fan: OFF, swing: OFF]
[16:22:11][D][SETTINGS:522]: Settings changed, updating HA states
[16:22:12][I][CN105:650]: power or mode changed
[16:22:12][D][CYCLE:327]: 3b: Receiving room °C response
[16:22:12][D][Decoder:256]: [Room °C: 20.000000]
[16:22:12][D][Decoder:257]: [OAT  °C: 9.000000]
[16:22:12][I][STATUS:128]: [received]-> [room C°: 20.0, operating: NO , compressor freq: nan Hz]
[16:22:12][I][STATUS:128]: [current]-> [room C°: 0.0, operating: NO , compressor freq: nan Hz]
[16:22:12][D][CN105:218]: setting action to -> 4
[16:22:12][D][CN105:267]: Climate mode is: 3
[16:22:12][D][CN105:268]: Climate action is: 4
[16:22:12][D][CYCLE:330]: 4a: Sending status request (0x06)
[16:22:12][D][CN105:323]: creating Info packet
[16:22:12][D][CN105:084]: writing packet...
[16:22:12][D][CYCLE:348]: 4b: Receiving status response
[16:22:12][D][Decoder:280]: [0x06 is status]
[16:22:12][I][STATUS:128]: [received]-> [room C°: 20.0, operating: YES, compressor freq: 24.0 Hz]
[16:22:12][I][STATUS:128]: [current]-> [room C°: 20.0, operating: NO , compressor freq: nan Hz]
[16:22:12][D][CN105:218]: setting action to -> 3
[16:22:12][D][CN105:267]: Climate mode is: 3
[16:22:12][D][CN105:268]: Climate action is: 3
[16:22:12][D][CYCLE:352]: 5a: Sending power request (0x09)
[16:22:12][D][CN105:323]: creating Info packet
[16:22:12][D][CN105:084]: writing packet...
WARNING <Hostname> @ <My IP Address>: Connection error occurred: [Errno 54] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for <Hostname> @ <My IP Address>
WARNING Disconnected from API
WARNING Can't connect to ESPHome API for <Hostname> @ <My IP Address>: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='<My IP address>', port=6053))]: [Errno 61] Connect call failed ('<My IP Address>', 6053) (SocketAPIError)

Other relevant information

  • I installed MitsubishiCN105ESPHome for the first time ~ 20 hours ago, and it worked beautifully for about 12 hrs. I then made some minor changes, recompiled (which involved a fresh pull of the repo), and all of a sudden, the unit would run for ~ 30 seconds, disconnect, then crash. It's possible this is simply a case of a newbie causing problems and not understanding what they did wrong.
  • Indoor unit: SVZ-KP36NA
  • Outdoor unit: SUZ-KA36NAHZ
  • Running on a Waveshare ESP32-C3-Zero (ESP32C3 160MHz, 320KB RAM, 4MB Flash).

My YAML

substitutions: 
  name: <name>
  friendly_name: ESPHome Heatpump

esphome:
  name: ${name}

esp32:
  board: esp32-c3-devkitm-1
  variant: ESP32C3
  framework:
    type: esp-idf

uart:
  id: HP_UART
  baud_rate: 2400
  rx_pin: GPIO20 # orange on CN105 connector
  tx_pin: GPIO21 # yellow on connector

# External component reference
external_components:
  - source: github://echavet/MitsubishiCN105ESPHome

wifi:
  ssid: "<ssid0>"
  password: "<password>"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "<ssid1>"
    password: "<password>"

captive_portal:

# Enable Logging
logger:
  # level: INFO
  # logs:
  #   EVT_SETS : INFO
  #   WIFI : INFO
  #   MQTT : INFO
  #   WRITE_SETTINGS : INFO
  #   SETTINGS : INFO
  #   STATUS : INFO
  #   CN105Climate: WARN
  #   CN105: INFO
  #   climate: WARN
  #   sensor: WARN
  #   chkSum : INFO
  #   WRITE : WARN
  #   READ : WARN
  #   Header: INFO
  #   Decoder : INFO
  #   CONTROL_WANTED_SETTINGS: INFO
## Swap the above settings with these debug settings for development or troubleshooting
 level: DEBUG
 logs:
   EVT_SETS : DEBUG
   WIFI : INFO
   MQTT : INFO
   WRITE_SETTINGS : DEBUG
   SETTINGS : DEBUG
   STATUS : INFO
   CN105Climate: WARN
   CN105: DEBUG
   climate: WARN
   sensor: WARN
   chkSum : INFO
   WRITE : WARN
   READ : WARN
   Header: INFO
   Decoder : DEBUG
   CONTROL_WANTED_SETTINGS: DEBUG

# Enable Home Assistant API
api:

# Enable OTA
ota:
  - platform: esphome
    password: "<password>"

# Enable Web server.
web_server:
  port: 80

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

# Text sensors with general information.
text_sensor:
  # Expose ESPHome version as sensor.
  - platform: version
    name: ESPHome Version
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: IP
    ssid:
      name: SSID
    bssid:
      name: BSSID

# Sensors with general information.
sensor:
  # Uptime sensor.
  - platform: uptime
    name: Uptime

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: WiFi Signal
    update_interval: 120s

# Create a button to restart the unit from HomeAssistant. Rarely needed, but can be handy.
button:
  - platform: restart
    name: "Restart ${friendly_name}"

# Climate entity configuration
climate:
  - platform: cn105
    id: hp
    name: "${friendly_name}"
    icon: mdi:heat-pump      
    visual:
      min_temperature: 15
      max_temperature: 24
      temperature_step:
        target_temperature: 0.5
        current_temperature: 0.5
    # Timeout and communication settings
    remote_temperature_timeout: 30min
    update_interval: 4s
    debounce_delay : 100ms
    # Various optional sensors, not all sensors are supported by all heatpumps
    compressor_frequency_sensor:
      name: Compressor Frequency
      entity_category: diagnostic
      disabled_by_default: false
    outside_air_temperature_sensor:
      name: Outside Air Temp
      disabled_by_default: false
    stage_sensor:
      name: Stage
      entity_category: diagnostic
      disabled_by_default: true
    sub_mode_sensor:
      name: Sub Mode
      entity_category: diagnostic
      disabled_by_default: true
    auto_sub_mode_sensor:
      name: Auto Sub Mode
      entity_category: diagnostic
      disabled_by_default: true
@drew-hill drew-hill changed the title API disconnect and potential crashing while sending Stage, Sub Mode, and Auto Sub Mode info. API disconnect and potential ESP32 crash while sending Stage, Sub Mode, and Auto Sub Mode info. Jan 6, 2025
drew-hill referenced this issue Jan 6, 2025
@somlefant
Copy link

Will probably be fixed when commit aa9f5a7 is merged.

@somlefant
Copy link

@drew-hill you can test the commit by temporarily changing the source in the yaml to:
github://echavet/MitsubishiCN105ESPHome@aa9f5a7204918a6eca2f575b8a290d13fcaefd24

@drew-hill
Copy link
Author

Thanks @somlefant. Appreciate the help. That does seem to have resolved my issue. Nothing but smooth sailing using that commit URL. Closing this issue with my comment as it appears to be resolved with the commit. Thanks!

@phidauex
Copy link
Collaborator

phidauex commented Jan 8, 2025

PR #213 has been merged, thanks for testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants