ESP8266 error after installing

After using the Home Assistant MELcloud integration I would like to know more about what my heat pump is doing. So I bought a Procon A1M melcobems to have a modbus connection to the heat pump. A RS485 converter than gives the signal to a ESP8266 (Wemos D1 mini) with ESPhome to make all available in Home Assistant. The idea is not new and code is already available. I got it from tweakers.net directly from one of the users and that code works.

Another user there expanded the code with a lot of useful things (but he uses a ESP32). So I tried to put that on the D1 mini. The installation appears to run without problems but after that the device doesn’t come online.

If I use a usb connection to read out the logs I get this:

User exception (panic/abort/assert)
--------------- CUT HERE F
User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Unhandled C++ exception: OOM

>>>stack>>>

ctx: cont
sp: 3ffffc50 end: 3fffffc0 offset: 0000
3ffffc50:  00000000 0082008f 00000000 4010024c  
3ffffc60:  000000fe 00000000 00000000 00000000  
3ffffc70:  00000000 00000000 00000000 00000001  
3ffffc80:  00007fff 00000000 00000002 3fff860c  
3ffffc90:  3fffb4b4 4020ad2a 00000020 4022988e  
3ffffca0:  3fffb4b4 4020ad2a 00000020 402298ad  
3ffffcb0:  00000002 00000000 00000020 40228ef8  
3ffffcc0:  3fffb49c 00000000 00000002 4020ad2a  
3ffffcd0:  3fffb4b4 00000010 3ffffd20 3fffb4a4  
3ffffce0:  3fff3fdc 00000045 3fff3fdc 00000000  
3ffffcf0:  3fff408c 3fff799c 3fff860c 4020c090  
3ffffd00:  00000002 4020c6dd 3fff1498 4020c0a8  
3ffffd10:  3ffffd40 3ffffd30 00000010 40214633  
3ffffd20:  3fff408c 3fff85a4 4022d55c 4022d540  
3ffffd30:  3fff79ac 3fff85a4 3fffbc54 40261824  
3ffffd40:  00000004 000000bf 3fffbc54 00000102  
3ffffd50:  3fff407c 00000046 3fff407c 402057a8  
3ffffd60:  6c656d6f 00000045 3fff3fdc 4020bce2  
3ffffd70:  4a200200 00000000 00000000 00000000  
3ffffd80:  00000000 3fffaa44 3fff1498 00000001  
3ffffd90:  3fff3f7c 00000044 3fff1498 4022d448  
3ffffda0:  3fff96ec 3ffffdc0 3fff1498 4022d500  
3ffffdb0:  3fff3fdc 00000045 3fff1498 40213eb1  
3ffffdc0:  00000043 00000043 3fffa954 40242428  
3ffffdd0:  0000011c 00000108 00000042 40212e72  
3ffffde0:  3fffa3b8 3fff1498 3fffa314 3fff1560  
3ffffdf0:  3fffa314 3fff1498 3fffa314 4021acec  
3ffffe00:  00000001 00000000 00000000 00000000  
3ffffe10:  00000000 feefef00 feefeffe feefeffe  
3ffffe20:  3ffffe28 0000000e 2d505345 7374694d  
3ffffe30:  73696275 00006968 00000000 00000000  
3ffffe40:  3ffffe48 00000009 666e6f63 73656769  
3ffffe50:  00000070 00000000 00000000 00000000  
3ffffe60:  140a0a01 140a0a29 ffffff01 00000000  
3ffffe70:  00000000 00000000 3fff3ef4 00000013  
3ffffe80:  0000001e 00000000 00000000 00000000  
3ffffe90:  00000000 00000000 3ffffea0 00000009 <
3ffffea0:  64696341 706f7020 00000073 00000000  
3ffffeb0:  00000000 00000000 140a0a01 140a0a29  
3ffffec0:  ffffff01 00000000 00000000 00000000  
3ffffed0:  3ffffed8 0000000b 3a69646d 2d77656e  
3ffffee0:  00786f62 006e6f69 3fffff60 00000001  
3ffffef0:  3ffffee8 00000001 3ffffee8 00000001  
3fffff00:  3ffffee8 00000001 3ffffee8 00000001  
3fffff10:  3ffffee8 00000001 3ffffee8 00000001  
3fffff20:  3ffffee8 00000001 3ffffee8 00000001  
3fffff30:  3ffffee8 00000001 3ffffee8 00000001  
3fffff40:  3ffffee8 00000001 3ffffee8 00000001  
3fffff50:  3ffffee8 00000001 3ffffee8 00000001  
3fffff60:  3fff8b5c feefeffe feefeffe feefeffe  
3fffff70:  3fffa218 000000b8 3fffa314 00000000  
3fffff80:  3ffe9b72 feefeffe feefeffe feefeffe  
3fffff90:  feefeffe feefeffe feefeffe 3fff19d4  
3fffffa0:  3fffdad0 00000000 3fff19c0 402293c8  
3fffffb0:  feefeffe feefeffe 3ffe86c4 40100701  
<<<stack<<<

last failed alloc call: 4020AD2A(32)

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

last failed alloc caller: 0x4020ad2a

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v0009d290
~ld

User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Unhandled C++ exception: OOM

>>>stack>>>

ctx: cont
sp: 3ffffc50 end: 3fffffc0 offset: 0000
3ffffc50:  00000000 0082008f 00000000 4010024c  
3ffffc60:  000000fe 00000000 00000000 00000000  
3ffffc70:  00000000 00000000 00000000 00000001  
3ffffc80:  00007fff 00000000 00000002 3fff860c  
3ffffc90:  3fffb4b4 4020ad2a 00000020 4022988e  
3ffffca0:  3fffb4b4 4020ad2a 00000020 402298ad  
3ffffcb0:  00000002 00000000 00000020 40228ef8  
3ffffcc0:  3fffb49c 00000000 00000002 4020ad2a  
3ffffcd0:  3fffb4b4 00000010 3ffffd20 3fffb4a4  
3ffffce0:  3fff3fdc 00000045 3fff3fdc 00000000  
3ffffcf0:  3fff408c 3fff799c 3fff860c 4020c090  
3ffffd00:  00000002 4020c6dd 3fff1498 4020c0a8  
3ffffd10:  3ffffd40 3ffffd30 00000010 40214633  
3ffffd20:  3fff408c 3fff85a4 4022d55c 4022d540  
3ffffd30:  3fff79ac 3fff85a4 3fffbc54 40261824  
3ffffd40:  00000003 000000bf 3fffbc54 00000102  
3ffffd50:  3fff407c 00000046 3fff407c 402057a8  
3ffffd60:  6c656d6f 00000045 3fff3fdc 4020bce2  
3ffffd70:  4a200200 00000000 00000000 00000000  
3ffffd80:  00000000 3fffaa44 3fff1498 00000001  
3ffffd90:  3fff3f7c 00000044 3fff1498 4022d448  
3ffffda0:  3fff96ec 3ffffdc0 3fff1498 4022d500  
3ffffdb0:  3fff3fdc 00000045 3fff1498 40213eb1  
3ffffdc0:  00000043 00000043 3fffa954 40242428  
3ffffdd0:  0000011c 00000108 00000042 40212e72  
3ffffde0:  3fffa3b8 3fff1498 3fffa314 3fff1560  
3ffffdf0:  3fffa314 3fff1498 3fffa314 4021acec  
3ffffe00:  00000001 00000000 00000000 00000000  
3ffffe10:  00000000 feefef00 feefeffe feefeffe  
3ffffe20:  3ffffe28 0000000e 2d505345 7374694d  
3ffffe30:  73696275 00006968 00000000 00000000  
3ffffe40:  3ffffe48 00000009 666e6f63 73656769  
3ffffe50:  00000070 00000000 00000000 00000000  
3ffffe60:  140a0a01 140a0a29 ffffff01 00000000  
3ffffe70:  00000000 00000000 3fff3ef4 00000013  
3ffffe80:  0000001e 00000000 00000000 00000000  
3ffffe90:  00000000 00000000 3ffffea0 00000009 <
3ffffea0:  64696341 706f7020 00000073 00000000  
3ffffeb0:  00000000 00000000 140a0a01 140a0a29  
3ffffec0:  ffffff01 00000000 00000000 00000000  
3ffffed0:  3ffffed8 0000000b 3a69646d 2d77656e  
3ffffee0:  00786f62 006e6f69 3fffff60 00000001  
3ffffef0:  3ffffee8 00000001 3ffffee8 00000001  
3fffff00:  3ffffee8 00000001 3ffffee8 00000001  
3fffff10:  3ffffee8 00000001 3ffffee8 00000001  
3fffff20:  3ffffee8 00000001 3ffffee8 00000001  
3fffff30:  3ffffee8 00000001 3ffffee8 00000001  
3fffff40:  3ffffee8 00000001 3ffffee8 00000001  
3fffff50:  3ffffee8 00000001 3ffffee8 00000001  
3fffff60:  3fff8b5c feefeffe feefeffe feefeffe  
3fffff70:  3fffa218 000000b8 3fffa314 00000000  
3fffff80:  3ffe9b72 feefeffe feefeffe feefeffe  
3fffff90:  feefeffe feefeffe feefeffe 3fff19d4  
3fffffa0:  3fffdad0 00000000 3fff19c0 402293c8  
3fffffb0:  feefeffe feefeffe 3ffe86c4 40100701  
<<<stack<<<

last failed alloc call: 4020AD2A(32)

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

last failed alloc caller: 0x4020ad2a

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v0009d290
~ld

Because of the OOM message I also tried a D1 mini pro which should have more memory but the problem remains. I have no clue where to start troubleshooting. I hope you have :slight_smile:

Edit:
Tried to remove all logger activity (level: none). Didn’t make a difference.

If I look at the installation log maybe memory isn’t the problem:

INFO Reading configuration /config/esphome/pro-mitsubishi.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp-warmtepomp (board: d1_mini_pro; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 16MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|-- <ESPAsyncWebServer-esphome> 2.1.0
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <DNSServer> 1.1.1
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|-- <ArduinoJson> 6.18.5
Compiling /data/esp-warmtepomp/.pioenvs/esp-warmtepomp/src/main.cpp.o
Linking /data/esp-warmtepomp/.pioenvs/esp-warmtepomp/firmware.elf
RAM:   [======    ]  55.9% (used 45800 bytes from 81920 bytes)
Flash: [======    ]  61.2% (used 639569 bytes from 1044464 bytes)
Building /data/esp-warmtepomp/.pioenvs/esp-warmtepomp/firmware.bin
esp8266_copy_factory_bin(["/data/esp-warmtepomp/.pioenvs/esp-warmtepomp/firmware.bin"], ["/data/esp-warmtepomp/.pioenvs/esp-warmtepomp/firmware.elf"])
========================= [SUCCESS] Took 7.42 seconds =========================
INFO Successfully compiled program.

Edit 2:
If I remove the last part of the yaml code with all the text_sensors the esp comes online immediately and displays all remaining sensors. If I add one then it won’t work. The strange thing is the first code I mentioned also has some of the same text_sensors and is working.

If remove most of the code, leaving only the text_sensors, then it works as well. So it goes wrong somewhere in the combination?

Update:
I have managed to get a working version without all the energy-related items. After that I added some of them in:

esphome:
  name: esp-warmtepomp
  comment: Mitsubishi warmtepomp

esp8266:
  board: d1_mini_pro

# Enable logging
logger:
  level: INFO
  baud_rate: 0

# Enable Home Assistant API
api:
#   encryption:
#     key: "jWKdOug+rBbCtzLRMgp+68RJp4ijwYbY9Fabwhx25a0="

ota:
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 10.10.20.41
    gateway: 10.10.20.1
    subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "ESP-Mitsubishi"
    password: "configesp"
    
captive_portal:
    
web_server:
  port: 80

uart:
  id: mod_bus
  tx_pin: D7
  rx_pin: D6
  baud_rate: 9600
  stop_bits: 1
  
modbus:
  #flow_control_pin: D5
  id: mitsubishi1
  send_wait_time: 2000ms

modbus_controller:
  - id: mitsubishi
    ## the Modbus device addr 1  (hex: 0x01)
    address: 0x01
    modbus_id: mitsubishi1
    setup_priority: -10
    #command_throttle: 250ms
    update_interval: 15s

sensor:
## FC04 registers (read)
    ## Frequentie
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_heat_pump_frequency_master
    name: "Heat Pump Frequency – Master"
    icon: mdi:sine-wave
    address: 0x20  ## Frequency - FC4: 32
    unit_of_measurement: "Hz"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 0

    ## DHW Temperature Drop
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_DHW_temperature_drop
    name: "DHW temperature drop"
    icon: mdi:thermometer-chevron-down
    address: 0x32 ## Room temperature - FC4: 50
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

    ## Room temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_room_temperature_zone_1
    name: "Room Temperature – Zone 1"
    icon: mdi:home-thermometer
    address: 0x34 ## Room temperature - FC4: 52
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

    ## Refrigerant liquid  temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_refrigerant_liquid_temperature
    name: "Refrigerant Liquid Temperature"
    icon: mdi:snowflake-thermometer
    address: 0x38  ## Refrigerant Liquid Temp - FC4: 56
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01
    
    ## Outdoor ambient temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_outdoor_temperature
    name: "Outdoor temperature"
    icon: mdi:thermometer
    address: 0x3A ## Outdoor ambient - FC4: 58
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

    ## Flow temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_flow_temperature
    name: "Flow temperature"
    icon: mdi:thermometer-auto
    address: 0x3C  ## Flow temperature - FC4: 60
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

    ## Return temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_return_temperature
    name: "Return temperature"
    icon: mdi:thermometer
    address: 0x3E ## Return temperature - FC 4: 62
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

    ## Tank water temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_tank_temperature
    name: "Tank temperature"
    icon: mdi:water-thermometer
    address: 0x40  ## Tank temperature - FC4: 64
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

    ## Flow temperature zone 1
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_flow_temperature_zone_1
    name: "Flow temperature - Zone 1"
    icon: mdi:thermometer
    address: 0x42  ## Flow temperature - FC4: 66
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

    ## Return temperature zone 1
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_return_temperature_zone_1
    name: "Return temperature - Zone 1"
    icon: mdi:thermometer
    address: 0x44 ## Return temperature - FC 4: 68
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

    ## Boiler flow temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_boiler_flow_temperature
    name: "Boiler flow temperature"
    icon: mdi:thermometer
    address: 0x4A  ## Bioler flow temperature - FC4: 74
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

    ## Boiler return temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_boiler_return_temperature
    name: "Boiler return temperature"
    icon: mdi:thermometer-lines
    address: 0x4C  ## Boiler return temperature - FC4: 76
    unit_of_measurement: "°C"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

    ## Heat pump run time x1
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_heat_pump_run_time_1
    address: 0x4F  ## Heat pump run time x1 - FC4: 79
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 0

    ## Heat pump run time x100
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_heat_pump_run_time_100
    address: 0x50  ## Heat pump run time x100 - FC4: 80
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 0
    filters:
      - multiply: 100

    ## Heat pump run time
  - platform: template
    id: mitsubishi_heat_pump_run_time
    name: "Heat pump run time"
    icon: mdi:wrench-clock
    unit_of_measurement: "hrs"
    accuracy_decimals: 0
    lambda: |-
      return id(mitsubishi_heat_pump_run_time_100).state + id(mitsubishi_heat_pump_run_time_1).state;
    update_interval: 60s    

    ## Energy used measurement year
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_energy_used_year
    address: 0x99  ## FC4: 153
    register_type: read
    value_type: U_WORD

    ## Energy used measurement month
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_energy_used_month
    address: 0x9A  ## FC4: 154 
    register_type: read
    value_type: U_WORD

    ## Energy used measurement day
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_energy_used_day
    address: 0x9B  ## FC4: 155
    register_type: read
    value_type: U_WORD
# 
#     ## Energy used heating kWh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_heating_kwh
#     address: 0x9C  ## FC4: 156
#     unit_of_measurement: "kWh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy used heating Wh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_heating_wh
#     address: 0x9D  ## FC4: 157
#     unit_of_measurement: "Wh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy used heating 
#   - platform: template
#     id: mitsubishi_energy_used_heating
#     name: "Energy used heating"
#     icon: mdi:heat-wave
#     device_class: energy
#     state_class: total_increasing
#     unit_of_measurement: "kWh"
#     accuracy_decimals: 3
#     lambda: |-
#       return id(mitsubishi_heating_kwh).state + (id(mitsubishi_heating_wh).state/100);
#     update_interval: 60s  
# 
#     ## Energy used cooling kWh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_cooling_kwh
#     address: 0x9E  ## FC4: 158
#     unit_of_measurement: "kWh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy used cooling Wh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_cooling_wh
#     address: 0x9F  ## FC4: 159
#     unit_of_measurement: "Wh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy used cooling 
#   - platform: template
#     id: mitsubishi_energy_used_cooling
#     name: "Energy used cooling"
#     icon: mdi:snowflake
#     device_class: energy
#     state_class: total_increasing
#     unit_of_measurement: "kWh"
#     accuracy_decimals: 3
#     lambda: |-
#       return id(mitsubishi_cooling_kwh).state + (id(mitsubishi_cooling_wh).state/100);
#     update_interval: 60s  
#   
#     ## Energy used SWW kWh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_sww_kwh
#     address: 0xA0  ## FC4: 160
#     unit_of_measurement: "kWh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy used SWW Wh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_sww_wh
#     address: 0xA1  ## FC4: 161
#     unit_of_measurement: "Wh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy used SWW 
#   - platform: template
#     id: mitsubishi_energy_used_sww
#     name: "Energy used SWW"
#     icon: mdi:water
#     device_class: energy
#     state_class: total_increasing
#     unit_of_measurement: "kWh"
#     accuracy_decimals: 3
#     lambda: |-
#       return id(mitsubishi_sww_kwh).state + (id(mitsubishi_sww_wh).state/100);
#     update_interval: 60s  
# 
    ## Energy produced measurement year
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_energy_produced_year
    #name: "Date produced measurement year"
    address: 0xA3  ## FC4: 163
    register_type: read
    value_type: U_WORD

    ## Energy produced measurement month
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_energy_produced_month
    #name: "Date produced measurement month"
    address: 0xA4  ## FC4: 164
    register_type: read
    value_type: U_WORD

    ## Energy produced measurement day
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_energy_produced_day
    #name: "Date produced measurement day"
    address: 0xA5  ## FC4: 165
    register_type: read
    value_type: U_WORD
# 
#     ## Energy produced heating kWh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_produced_heating_kwh
#     address: 0xA6  ## FC4: 166
#     unit_of_measurement: "kWh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy produced heating Wh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_produced_heating_wh
#     address: 0xA7  ## FC4: 167
#     unit_of_measurement: "Wh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy produced heating 
#   - platform: template
#     id: mitsubishi_energy_produced_heating
#     name: "Energy produced heating"
#     icon: mdi:heat-wave
#     device_class: energy
#     state_class: total_increasing
#     unit_of_measurement: "kWh"
#     accuracy_decimals: 3
#     lambda: |-
#       return id(mitsubishi_produced_heating_kwh).state + (id(mitsubishi_produced_heating_wh).state/100);
#     update_interval: 60s
# 
#     ## Energy produced cooling kWh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_produced_cooling_kwh
#     address: 0xA8  ## FC4: 168
#     unit_of_measurement: "kWh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy produced cooling Wh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_produced_cooling_wh
#     address: 0xA9  ## FC4: 169
#     unit_of_measurement: "Wh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy produced cooling 
#   - platform: template
#     id: mitsubishi_energy_produced_cooling
#     name: "Energy produced cooling"
#     icon: mdi:snowflake
#     device_class: energy
#     state_class: total_increasing
#     unit_of_measurement: "kWh"
#     accuracy_decimals: 3
#     lambda: |-
#       return id(mitsubishi_produced_cooling_kwh).state + (id(mitsubishi_produced_cooling_wh).state/100);
#     update_interval: 60s
# 
#     ## Energy produced SWW kWh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_produced_sww_kwh
#     address: 0xAA  ## FC4: 170
#     unit_of_measurement: "kWh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy produced SWW Wh
#   - platform: modbus_controller
#     modbus_controller_id: mitsubishi
#     id: mitsubishi_produced_sww_wh
#     address: 0xAB  ## FC4: 171
#     unit_of_measurement: "Wh"
#     device_class: energy
#     state_class: total_increasing
#     register_type: read
#     value_type: U_WORD
# 
#     ## Energy produced SWW 
#   - platform: template
#     id: mitsubishi_energy_produced_sww
#     name: "Energy produced SWW"
#     icon: mdi:water
#     device_class: energy
#     state_class: total_increasing
#     unit_of_measurement: "kWh"
#     accuracy_decimals: 3
#     lambda: |-
#       return id(mitsubishi_produced_sww_kwh).state + (id(mitsubishi_produced_sww_wh).state/100);
#     update_interval: 60s
# 
#     ## COP heating
#   - platform: template
#     id: mitsubishi_cop_heating
#     name: "COP Heating"
#     icon: mdi:slash-forward-box
#     accuracy_decimals: 2
#     lambda: |-
#       return (id(mitsubishi_produced_heating_kwh).state + (id(mitsubishi_produced_heating_wh).state/100)) / (id(mitsubishi_heating_kwh).state + (id(mitsubishi_heating_wh).state/100));
#     update_interval: 60s    
# 
#     ## COP Cooling
#   - platform: template
#     id: mitsubishi_cop_cooling
#     name: "COP Cooling"
#     icon: mdi:slash-forward-box
#     accuracy_decimals: 2
#     lambda: |-
#       return (id(mitsubishi_produced_cooling_kwh).state + (id(mitsubishi_produced_cooling_wh).state/100)) / (id(mitsubishi_cooling_kwh).state + (id(mitsubishi_cooling_wh).state/100));
#     update_interval: 60s  
# 
#     ## COP SWW
#   - platform: template
#     id: mitsubishi_cop_sww
#     name: "COP SWW"
#     icon: mdi:slash-forward-box
#     accuracy_decimals: 2
#     lambda: |-
#       return (id(mitsubishi_produced_sww_kwh).state + (id(mitsubishi_produced_sww_wh).state/100)) / (id(mitsubishi_sww_kwh).state + (id(mitsubishi_sww_wh).state/100));
#     update_interval: 60s  

    ## Flow
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_flow
    name: "Flow"
    icon: mdi:arrow-right-bold-circle
    address: 0xAD ## Flow - FC4: 173
    unit_of_measurement: "l/min"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1

## FC03 registers (holding)

    ## Set tank temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_target_tank_temperature
    name: "Target tank temperature"
    icon: mdi:water-thermometer-outline
    address: 0x1F ## FC3: 31
    unit_of_measurement: "°C"
    register_type: holding
    value_type: U_WORD
    filters:
      - multiply: 0.01

    ## Target room temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_target_room_temperature
    name: "Target room temperature"
    icon: mdi:home-thermometer-outline
    address: 0x20 ## FC3: 32
    unit_of_measurement: "°C"
    register_type: holding
    value_type: U_WORD
    filters:
      - multiply: 0.01

    ## Set flow temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_set_flow_temperature
    name: "Target flow temperature"
    icon: mdi:thermometer-auto
    address: 0x55 ## FC3: 85
    unit_of_measurement: "°C"
    register_type: holding
    value_type: U_WORD
    filters:
      - multiply: 0.01

number:
    ## Set tank temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_set_tank_temperature
    name: "Set target tank temperature"
    icon: mdi:water-thermometer-outline
    address: 0x1F ## FC3: 31
    unit_of_measurement: "°C"
    register_type: holding
    value_type: U_WORD
    mode: box
    step: 0.5
    entity_category: config
    min_value: 30
    max_value: 59
    lambda: "return  x / 100; "
    write_lambda: |-
      uint16_t newtemp = x*100;
      ESP_LOGI("main", "Set tank temperature %d", newtemp);
      // Create a modbus command item with the flow temperature as the payload
      esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(mitsubishi, 0x1E, newtemp);
      // Submit the command to the send queue
      mitsubishi->queue_command(set_payload_command);
      return {}; 

    ## Set room temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_set_room_temperature
    name: "Set target room temperature"
    icon: mdi:home-thermometer
    address: 0x20 ## FC3: 32
    unit_of_measurement: "°C"
    register_type: holding
    value_type: U_WORD
    mode: box
    step: 0.5
    entity_category: config
    min_value: 15
    max_value: 25
    lambda: "return  x / 100; "
    write_lambda: |-
      uint16_t newtemp = x*100;
      ESP_LOGI("main", "Set room temperature %d", newtemp);
      // Create a modbus command item with the flow temperature as the payload
      esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(mitsubishi, 0x20, newtemp);
      // Submit the command to the send queue
      mitsubishi->queue_command(set_payload_command);
      return {}; 

    ## Set legionella temperature
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_set_legionella_temperature
    name: "Set target legionella prevention temperature"
    icon: mdi:bacteria-outline
    address: 0x59 ## FC3: 89
    unit_of_measurement: "°C"
    register_type: holding
    value_type: U_WORD
    mode: box
    step: 0.5
    entity_category: config
    min_value: 15
    max_value: 85
    multiply: 100

switch:
    ## Force SWW run
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_force_sww
    name: "Set force SWW"
    icon: mdi:fire-alert
    address: 0x25 ## FC3: 37
    register_type: holding
    #value_type: U_WORD
    write_lambda: |-
      uint16_t forceSWW = x;
      ESP_LOGI("main", "Set force SWW %d", x);
      // Create a modbus command item with the flow temperature as the payload
      esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(mitsubishi, 0x25, forceSWW);
      // Submit the command to the send queue
      mitsubishi->queue_command(set_payload_command);
      return {};

    ## Set vacation mode
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_set_vacation
    name: "Set vacation mode"
    icon: mdi:briefcase
    address: 0x26 ## FC3: 38
    register_type: holding
    #value_type: U_WORD
    write_lambda: |-
      uint16_t vacation = x;
      ESP_LOGI("main", "Set vacation mode %d", x);
      // Create a modbus command item with the flow temperature as the payload
      esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(mitsubishi, 0x26, x);
      // Submit the command to the send queue
      mitsubishi->queue_command(set_payload_command);
      return {};

text_sensor: 
    ## Defrost mode
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_defrost
    name: "Defrost"
    icon: mdi:snowflake-melt
    address: 0x1A ## FC4: 26
    register_type: read
    bitmask: 0
    raw_encode: HEXBYTES
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      ESP_LOGD("main", "Value for defrost mode %d", value);
      switch (value) {
        case 0: return std::string("Off");
        case 1: return std::string("Standby");
        case 2: return std::string("Defrost");
        case 3: return std::string("Waiting restart");
        default: return std::string("Unknown");
      }
      return x;

    ## Residual heat removal
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_residual_heat_removal
    name: "Residual heat removal"
    icon: mdi:car-defrost-rear
    address: 0x1B ## FC4: 27
    register_type: read
    bitmask: 0
    raw_encode: HEXBYTES
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      ESP_LOGD("main", "Value for residual heat removal %d", value);
      switch (value) {
        case 0: return std::string("Normal");
        case 1: return std::string("Prepared");
        case 2: return std::string("Residual heat removal");
        default: return std::string("Unknown");
      }
      return x;

    ## System On/Off
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_system_onoff
    name: "System On/Off"
    icon: mdi:power
    address: 0x19 ## FC3: 25
    register_type: holding
    bitmask: 0
    raw_encode: HEXBYTES
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      ESP_LOGD("main", "Value for system on/off %d", value);
      switch (value) {
        case 0: return std::string("Off");
        case 1: return std::string("On");
        default: return std::string("Unknown");
      }
      return x;
    
    ## System operating mode
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_operating_mode
    name: "System operating mode"
    icon: mdi:message-question-outline
    address: 0x1A ## FC3: 26
    register_type: holding
    bitmask: 0
    raw_encode: HEXBYTES
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      ESP_LOGD("main", "Value for system operating mode %d", value);
      switch (value) {
        case 0: return std::string("Stop");
        case 1: return std::string("Hot Water");
        case 2: return std::string("Heating");
        case 3: return std::string("Cooling");
        case 4: return std::string("Freeze Stat");
        case 6: return std::string("Electric heater");
        default: return std::string("Unknown");
      }
      return x;
      
    ## System SWW operating mode
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_sww_operating_mode
    name: "System SWW operating mode"
    icon: mdi:car-cruise-control
    address: 0x1B ## FC3: 27
    register_type: holding
    bitmask: 0
    raw_encode: HEXBYTES
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      ESP_LOGD("main", "Value for SWW operating mode %d", value);
      switch (value) {
        case 0: return std::string("Normal");
        case 1: return std::string("Eco");
        default: return std::string("Unknown");
      }
      return x;

    ## System heating mode
  - platform: modbus_controller
    modbus_controller_id: mitsubishi
    id: mitsubishi_heating_mode
    name: "System heating mode"
    icon: mdi:radiator
    address: 0x1C ## FC3: 28
    register_type: holding
    bitmask: 0
    raw_encode: HEXBYTES
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      ESP_LOGD("main", "Value for heating mode %d", value);
      switch (value) {
        case 0: return std::string("Heating room temperature");
        case 1: return std::string("Heating flow temperature");
        case 2: return std::string("Heating curve");
        case 3: return std::string("Cooling room temperature");
        case 4: return std::string("Cooling flow temperature");
        case 5: return std::string("Heating startup procedure");
        default: return std::string("Unknown");
      }
      return x;

  - platform: template
    name: "Energy used date"
    icon: mdi:clipboard-text-clock
    lambda: |-
      std::string year = to_string((int)(id(mitsubishi_energy_used_year).state));
      std::string month = to_string((int)(id(mitsubishi_energy_used_month).state));
      std::string day = to_string((int)(id(mitsubishi_energy_used_day).state));
      return day + "-" + month + "-" + year;
    update_interval: 60s

  - platform: template
    name: "Energy produced date"
    icon: mdi:clipboard-text-clock
    lambda: |-
      std::string year = to_string((int)(id(mitsubishi_energy_produced_year).state));
      std::string month = to_string((int)(id(mitsubishi_energy_produced_month).state));
      std::string day = to_string((int)(id(mitsubishi_energy_produced_day).state));
      return day + "-" + month + "-" + year;
    update_interval: 60s
# 
#   - platform: wifi_info
#     ip_address:
#       name: "Device IP Address"
#     ssid:
#       name: "Device Wi-Fi SSID"
#     bssid:
#       name: "Device Wi-Fi BSSID"
#   - platform: version
#     name: "ESPHome Version"
#     hide_timestamp: true

The webinterface is showing and the log. The log shows this error:

For the record: bought a Wemos D32 Pro and all the code is working perfectly now.

2 Likes

Hi there,

I have Ecodan air to water heat pump and I am trying to read and control from home assistant.

  1. Is there a list of items that I need to purchase in order to achieve my goal?
  2. Can I still use the Ecodan WiFi module that is currently connected to the CN105?
  3. If you have Ecodan working, r you able to assist me to get it going fastly - I am happy to pay you for your professional fee - if interested DM me on deyanshkodrov78 at gmail.com
  1. You can start with MELcloud. You can control the essential stuff. Maybe that’s enough for you? See Mitsubishi MELCLOUD integration with Home Assistant.
    Or you can go with the procon way. You need a Procon A1M melcobems mini (you can find it on ebay.co.uk sometimes), a modbus RS-485 adapter to USB (something like this) or to a ESP32 (example).
  2. You can only connect one device so you need to chose between the wifi module or the procon.
  3. I have it working but I don’t have the spare time to help you in that way. You can find the esphome code in the link (5) in the first post.