Connecting Home Ass...
 
Notifications
Clear all

Connecting Home Assistant to a Midea Heat Pump

207 Posts
15 Users
54 Reactions
25.8 K Views
cathodeRay
(@cathoderay)
Famed Member Moderator
9921 kWhs
Joined: 3 years ago
Posts: 1997
Topic starter  

Posted by: @gorm

May be, but also be the author know what he down. I dont know so much about this.
We will see, I looked in Visual Studio. There are about 3600 lines.

All he has done is use the modbus register address tables, and then wrapped it in that complex code. For example, he uses this to get the ambient temp:

  - platform: modbus_controller
    id: ${heat_pump_name}_107 # Outdoor ambient temperature 
    name: "hp_T4_outdoor_temperature"
    state_class: measurement
    register_type: holding
    address: 0x6B
    unit_of_measurement: "°C"
    value_type: S_WORD

whereas I do the same thing with:

    ambient = instrument.read_register(107, 0)

Nor do I need things like Visual Studio, I can edit my code in something like Notepad++. 

My entire code for collecting the minute by minute data is less than 100 lines. Complexity and obfuscation are not virtues!

 

 

Midea 14kW (for now...) ASHP heating both building and DHW


   
👍
1
ReplyQuote
(@cashback)
Trusted Member Member
187 kWhs
Joined: 2 years ago
Posts: 27
 

Posted by: @cathoderay

whereas I do the same thing with:

    ambient = instrument.read_register(107, 0)

Nor do I need things like Visual Studio, I can edit my code in something like Notepad++. 

Watch out, you have a bug: You need to set the fourth argument to `true` in order to read the ambient temperature as a signed value as it is `false` by default (and presumably by virtue of adding the fourth arg, the third argument should be set to `3`, the default, to set the function code to read register). I think this is the only temperature value that needs to deal with signed integers (if any of your others start to read negative, you have bigger real world problems to worry about!)

 


   
ReplyQuote
cathodeRay
(@cathoderay)
Famed Member Moderator
9921 kWhs
Joined: 3 years ago
Posts: 1997
Topic starter  

@cashback - well spotted, thanks! It is also an example of why it is a good idea to post code so others can inspect it!

It looks as though the collected data got set to zero when it should have been negative. Here's the local Met Office weather station data for the night of 3/4 April showing a period below zero: 

 

image

 

and here's my data covering the same period (green line is ambient):

 

image

  

Midea 14kW (for now...) ASHP heating both building and DHW


   
ReplyQuote
(@filipe)
Estimable Member Member
466 kWhs
Joined: 2 years ago
Posts: 62
 

Posted by: @cashback

If you're using the Home Assistant Node-RED addon, you should be able to download the following configuration, and import to Node-RED to get started:

 

GIST.GITHUB.COM "https://gist.github.com/benlancaster/3c416d8e0cb9f3c1ea22beb921f4a48a"
Midea ASHP Node-RED.json · GitHub
GitHub Gist: instantly share code, notes, and snippets.

 

If I get a chance, I will go through and update the Description blocks for all the pertinent sections. There's lots to improve still, so it may change, but I'm minded to go down the route of creating a "proper" integration now that I have a working reference integration.

Many caveats:

  • The sensor names are not particularly well done (they don't have a common prefix)
  • "It works on my machine", it may very well not work on yours
  • Zero warranty
  • ... probably more

Consider it licensed under WTFPL.

Hello @cashback

 

I got my Raspberry Pi 3B up and running HA on Friday evening 😎. I’ve spent the last few days getting Node-Red, MQTT-IO, HACS, Midea_ac_lan and other Integrations for stuff I have up and running. HACS was the perhaps the worse, but I eventually found the command needed and got Terminal installed to run it. I then wondered why I didn’t show on the side bar, but eventually spotted it in Integrations and ran the installer. The Midea doesn’t do much, but it’s doesn’t drop out like their App. The only useful thing was the DHW Tank Temperature and the status information for DHW and Heating.

I bought a Modbus RS485 to USB so I guess that is  next. What HACS integration did you start with? 

Phil


   
ReplyQuote
(@filipe)
Estimable Member Member
466 kWhs
Joined: 2 years ago
Posts: 62
 

Hi @gorm 

So this uses an ESP8266 board? I have bought 3 Wemos 8266 D1 mini boards and 5 DT18B20 to enable monitoring the flow and return temperatures across the input and output of my plate heat exchanger and the DHW tank temperature. It stuck me that ESPHome is so convenient for interfacing to sensors via WiFi (I have BT Mesh Wifi Disks which give good coverage).

Could you explain the kit you use and the steps in a bit more detail.

 

Many Thanks Phil

 

 


   
ReplyQuote
(@cashback)
Trusted Member Member
187 kWhs
Joined: 2 years ago
Posts: 27
 

Posted by: @filipe

I got my Raspberry Pi 3B up and running HA on Friday evening 😎.

Make sure you have a high endurance SD card! I was running on a Pi3B for a time but it was getting through SD cards like nobody's business. They're not very capable boards so you may find you run in to the limitations sooner than later.

Posted by: @filipe

What HACS integration did you start with? 

I didn't! Just the Node-RED Addon and associated Integration.

 


   
ReplyQuote



Transparent
(@transparent)
Illustrious Member Moderator
12949 kWhs
Veteran Expert
Joined: 3 years ago
Posts: 2276
 

Posted by: @cashback

Make sure you have a high endurance SD card

I would go a step beyond that recommendation.

The pioneering development of on-chip wear-levelling algorithms was undertaken by the Israeli firm, M-Systems.

In effect, there is an embedded processor which monitors the number of write-cycles to each memory location, and shares the data across the memory cells.
Each memory bank also has in-built redundancy, allowing write-intensive use under critical conditions.
M-Systems designed an system to shield users from handling that operation, and instead present a standard 'disc interface' which could be used by ordinary computers.
This was named True Flash Filing System.

After exchanging patents information in 2004, M-Systems was acquired outright by SanDisk two years later.

Sandisk offer three different strategies for wear-leveling which is still ahead of their major competitors.
The top-most product specification is normally only used for military and satellite development, and is manufactured solely in Western countries.

If you require SD card memory with error rates that are guaranteed, then SanDisk are most likely to be able to deliver that.

Samsung also use some M-systems technology under licence within their NAND-Flash product range.

It's too easy for other manufacturers to claim 'high endurance' without actually being able to guarantee that for each device.

Save energy... recycle electrons!


   
👍
2
ReplyQuote
(@cashback)
Trusted Member Member
187 kWhs
Joined: 2 years ago
Posts: 27
 

Posted by: @cathoderay

Given this basic setup, there is no need for modbus to be complex, and that's why I like minimal modbus (the python module) because it truly lives up to its name, a minimal but still human readable modbus interface for python. All you have to do is set the modbus parameters (baud rate, which is how fast the communication is, and various other parameters), name the slave, and then read or write to register addresses. It really is that simple. If you do it over a copper wire connection rather than wifi, it stays simple (two wires) and robust.

I've started writing a Midea Modbus client library. It looks like MinimalModbus is completely synchronous as far as I can tell, is that the case? I'm not sure I'll continue with it to be honest, the lack of TCP is a pretty major limiting factor.


   
ReplyQuote
cathodeRay
(@cathoderay)
Famed Member Moderator
9921 kWhs
Joined: 3 years ago
Posts: 1997
Topic starter  

Posted by: @filipe

What HACS integration did you start with? 

 

I didn't!

Indeed. HACS is a Right Royal PITA, bloated and painful to use. Most HA add-ons (integration is another bit of HA comedy jargon) can be installed manually, and if you do that you know you have added so that when you come to get rid of the add-on, as often you will, you know how to remove it cleanly.

There are two SSH/Terminal add-ons, the 'official' one and the HACS one. The former is crippleware, the latter is specifically designed to remove some but not all of the HA 'we know better than you' crippleware limitations. Once you have installed the latter, you have to disable Protected Mode, and then you can get something approaching root access using 'docker exec -it homeassistant bash' on the command line. You can then use most Linux command line tools, run python scripts and use pip to install modules etc.

You can get a perfectly usable mini PC with more capability, more ports and proper memory for for the same price or less than the price of a Raspberry Pi. A fanless unit is also silent and uses very little power.

Posted by: @cashback

I'm not sure I'll continue with it to be honest, the lack of TCP is a pretty major limiting factor.

This is only a problem if you want to connect over the internet. It is not necessary, a single wire is simpler and more robust. For a beginner, there is absolutely nothing to be gained by adding superfluous layers of complexity. I could use a helicopter to get from the ground floor on my home to the first floor, the winch man lifting me out though a ground floor window and then swinging me in through a first floor window, and while enthusiasts might enjoy the challenge of doing this (what could possibly go wrong?), I'll be sticking to using the stairs for the time being.

Another major plus in minimalmodbus is the simplicity of the code, which is also very well documented by python standards. Ramshackle, chaotic and obfuscated code with cavernous indents meaningless to man is best left to the python sado-masochists.    

    

Midea 14kW (for now...) ASHP heating both building and DHW


   
ReplyQuote
(@cashback)
Trusted Member Member
187 kWhs
Joined: 2 years ago
Posts: 27
 

Posted by: @cathoderay

Most HA add-ons (integration is another bit of HA comedy jargon) ...

Not quite, there's an important distinction between an Addon and an Integration. An addon adds functionality in the form of standalone "appliance", an integration integrates an existing platform/service/device/whatever to Home Assistant functionality.

Node-RED is a great example as there's both an Addon and an Integration. The Addon gives you an instance of Node-RED to play with. The Integration allows you to integrate your Node-RED instance in to Home Assistant.

One Adds functionality, the other Integrates with existing functionality. Not jargon at all.

Posted by: @cathoderay

Posted by: @cashback

The lack of TCP is a pretty major limiting factor.

This is only a problem if you want to connect over the internet. It is not necessary, a single wire is simpler and more robust. For a beginner, there is absolutely nothing to be gained by adding superfluous layers of complexity.   

No, that's not right. Modbus over TCP is extremely useful for local control over a local network. For example, my Midea controller is in the garage and currently hooked up to my Home Assistant via USB Modbus device sat right next to it. However, I also have a DIN rail mounted Modbus to power-over-ethernet adapter which I would like to use to develop my client library since it removes the need for physical access to the device (and my desk is 15 metres away and I don't fancy setting it up in the garage). It's still a single wire in and a single wire out.

You can also have multiple computers communicate with a TCP Modbus device, whereas you can only connect one to a USB Modbus device.

 

This post was modified 2 years ago 2 times by cashback

   
👍
1
ReplyQuote
(@filipe)
Estimable Member Member
466 kWhs
Joined: 2 years ago
Posts: 62
 

Posted by: @transparent

If you require SD card memory with error rates that are guaranteed, then SanDisk are most likely to be able to deliver that.

Interesting. Amazon showed a kit with power supply and SanDisk Ultra microSD card. I had better back it up from time to time to my PC, just in case. So far it seems ok - I’m glad to know it has smart technology to make it last longer.

Phil

 


   
ReplyQuote
cathodeRay
(@cathoderay)
Famed Member Moderator
9921 kWhs
Joined: 3 years ago
Posts: 1997
Topic starter  

More Home Assistant sh!te - why you really need Home Assistant like you need a hole in the head. After being nagged, I manually updated the HA core/OS the day before yesterday. Afterwards, everything seemed fine, only it wasn't. The update destroyed my python setup and reinstalled python 3.10 without retaining the minimalmodbus module I had added (pip install minimalmodbus etc). Of course, no warnings, and the only advice I will now be sure to get is RTFM...

Now, where's my brace and bit, I need to drill another hole in my head to relieve the intracranial pressure caused by HA...

The reason why I haven't written up the Beginner's Guide to Heat Pump Monitoring V2 'how to' posts is because I still have a hybrid system, with HA (not) doing some things in the background. Worst of both worlds, can't recommend it to anyone. I need to ditch HA entirely and set up an alternative system, but I have other calls on my time these days, so it'll have to wait, not that there is any urgency, the heating season is all but over.  

Midea 14kW (for now...) ASHP heating both building and DHW


   
ReplyQuote



Page 13 / 18
Share:

Join Us!

Heat Pump Dramas?

Thinking about installing a heat pump but unsure where to start? Already have one but it’s not performing as expected? Or are you locked in a frustrating dispute with an installer or manufacturer? We’re here to help.

Pre-Installation Planning
Post-Installation Troubleshooting
Performance Optimisation
✅ Complaint Support (Manufacturer & Installer)

👉 Book a one-to-one consultation now.

Latest Posts

x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security