Connecting to Midea...
 
Notifications
Clear all

Connecting to Midea MSmartHome using a PC

364 Posts
13 Users
22 Reactions
49.5 K Views
(@derek-m)
Illustrious Member Member
Joined: 4 years ago
Posts: 4428
 

Posted by: @cathoderay
@marekk and @iancalderbank - a first draft of my proposed layout. After much time spent down ESP rabbit holes I just about decided on balance the ESP route makes marginally more sense than the RPi Pico W route. In many ways, including cost, they are very similar, but the deciding fact for me all said and done ESP is currently more integrated with HA via ESP Home. In time, I think that may change, as more people use RPi Pico Ws with HA, but we are where we are now. That said, most of the ESP/HA forum threads are dossiers of despair, a litany of failed connections especially by beginners like me, but there are occasional positive results. But the current situation with HA/RPi Pico W is even worse, there is almost nothing out there yet (though that may change in time). Here's my proposed schematic:
 
Proposed components and connections

 

As you can see, I have proposed using a wired ethernet connection, with added PoE (Power over Ethernet). It solves the power supply problem, and was the robustness of wires (I am not sure how well those PCB trace antennae will get wifi through my solid stone walls, and it would be a real nuisance to buy the kit and have it not work).

The mini PC, router and Midea wired controller are already in place. The new additions are:

(1) PoE injector: about a tenner off ebay eg here (<=link)

(2) PoE ethernet enabled ESP32: these are more expensive, but they potentially solve a number of problems. Possible candidate here (<=link)

(3) I'm still working on details for the other three sensors (the ones in the left hand box will be later additions, once the basics are set up)

(4) Cables as shown

Any thoughts/comments very welcome, as ever!      

 
 

Can the ESP32 accept PT100 Resistance Temperature Detectors?

These are relatively cheap and quite accurate and could be obtained readily from TC Direct, who have both indoor and outdoor variations.

 


   
ReplyQuote
(@Anonymous 5046)
Active Member
Joined: 2 years ago
Posts: 10
 

Posted by: @derek-m

Can the ESP32 accept PT100 Resistance Temperature Detectors?

shortly: yes, but...

PT100 is as you said resistance temp sensor, therefore it would require analog to digital conversion (ADC). ESP8266 has only one such port, if you wish to add more then need to use ESP32: has 16 analog ports, code is backward compatible with ESP8266.

ESPHome with NTC sensors

Second but: there is something better (in my opinion) - DS18B20

It is  a 1-WIRE digital temperature sensor. Each DS18B20 temperature sensor has a unique 64-bit serial code. This allows you to wire multiple sensors to the same data wire. So, you can get temperature from multiple sensors using a single GPIO (I personally tested twenty conected to one line each on 3m cable).

you can buy in waterproof protection with different lenght of cables, the more you buy they cheaper will get, I see  £9 per 5 on ebay, and probably even cheaper on AliExpress

image

you need one resistor:

image

If you will to explore more about temp sensors here is nice reading: link

ESPHome with DS18B20

 

Remark: I advertise ESPHome as it has best integration with HomeAssistant, but there are others working on ESP8266 like ESPEasy or Tasmota

This post was modified 2 years ago by Anonymous

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

Posted by: @derek-m

Could you explain which of the midea_ac_lan routines you used to obtain the messages, particularly the type 4 showing power in and power out.

I didn't actively do anything, I just copied the developer's code into HA as a custom component, and enabled it. The workings of the code that obtains (gets) the messages is still beyond me. In the debug logs, the 01 messages appears as sent/received pairs (as in sent from/received by midea_ac_lan) every minute of so, but the 04 messages just appear as received, there is no corresponding sent message, mostly but not always on the hour. The code that sends the 01 message appears to be in \core\device.py:

    def send_message(self, data):
        if self._protocol == 3:
            self.send_message_V3(data, msg_type=MSGTYPE_ENCRYPTED_REQUEST)
        else:
            self.send_message_V2(data)

    def send_message_V2(self, data):
        if self._socket is not None:
            self._socket.send(data)

    def send_message_V3(self, data, msg_type=MSGTYPE_ENCRYPTED_REQUEST):
        data = self._security.encode_8370(data, msg_type)
        self.send_message_V2(data)

    def build_send(self, cmd):
        data = cmd.serialize()
        _LOGGER.debug(f"[{self._device_id}] Sending: {cmd}")
        msg = PacketBuilder(self._device_id, data).finalize()
        self.send_message(msg)

The V2/V3 stuff is about the different Midea protocols, the current V3 protocol messages, unlike previous protocol versions, use encryption (the so called 8370 encoding). What I see here is def build_send() sets up the message and send it to def send_message(), after logging the sending (which seems premature, as it hasn't actually been sent at that point in time, but there's no accounting for coding!). But 04 type messages (that you ask about above) don't get a 'Sending:' log entry, so they either get sent a different way, or don't get sent at all; instead, maybe the wired controller broadcasts then every hour or so, and all midea_ac_lan has to do is receive them?

I have tried to work out how cmd (which becomes the message) is assembled, without success. Stepping back through the code, it gets painfully recursive, and I end up lost. I have also looked for some sort of timer that times when to send the messages, but can't see anything obvious.

Posted by: @derek-m

I think that it may be quite feasible to add the code to extract further data from the controller, assuming that it is present [emphasis added].

It seems to me there us something present, but we don't know what it is. I remain convinced the developer of the modified midea_ac_lan code (the code that receives and processes the 04 messages) has some inside knowledge or way of looking that things that allows the developer to know what to find in the message, possibly even how to process it. I have left messages on the relevant github page but so far no reply.

Posted by: @derek-m

Can the ESP32 accept PT100 Resistance Temperature Detectors?

See @marekk's helpful reply.

 

  

 

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


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

@marekk - again, thanks again for the information and practical detail, it is very helpful.

I meant to add yesterday that the controller (I was thinking ESP32 rather ESP8266 - any particular reason you have used the latter?) that will be in the airing cupboard, next to the wired controller, and all the wiring runs from there are feasible, either through under floor board space or through the attic (being on the first floor, the airing cupboard abuts both). The outdoor temp sensor wire for example can run up through the attic to the eaves, where it will be sheltered from direct sunlight.   

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


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

I am now also wondering whether PoE is such a good idea after all. I do have a mains supply in the airing cupboard (supplies the remote wireless thermostat receiver, and powers the radiator circulating pump). It's currently a switched fused supply, no 13A socket, but I am sure I can get power from it without burning the house down. A 13A to low voltage DC power supply unit could then supply all the power needs, more simply and probably more cheaply, than using PoE. I still favour wired data connections though, old habits are slow to die! 

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


   
ReplyQuote
(@iancalderbank)
Noble Member Contributor
Joined: 3 years ago
Posts: 643
 

Posted by: @cathoderay

@marekk - again, thanks again for the information and practical detail, it is very helpful.

I meant to add yesterday that the controller (I was thinking ESP32 rather ESP8266 - any particular reason you have used the latter?) that will be in the airing cupboard, next to the wired controller, and all the wiring runs from there are feasible, either through under floor board space or through the attic (being on the first floor, the airing cupboard abuts both). The outdoor temp sensor wire for example can run up through the attic to the eaves, where it will be sheltered from direct sunlight.   

 

ESP 8266's and 32's do fundamentally the same job. the 32's are just more powerful (cpu, ram) and have more capability, in return for being (a bit) larger and (a bit) more expensive. If for example you wanted to do PWM control, you need a 32 as it does PWM in hardware, 8266 only does it in s/w and it doesn't work very well (I tried it).

ref the other comment on temp sensors - DS18B20's definitely the way to go. I have 15 of them wired to a single digital input on an ESP in my airing cupboard. works perfectly. and they cost next to nothing.

I started with ESP8266's as I knew no better, but anything new that I build, I use an ESP32 - UNLESS it happens to come as ready made board for a specific purpose with an 8266 on it from the manufactur.

PoE is a valid way to provide power for the ESP32 as per your diagram.

the other way, is just to run cat 5 for the ethernet without the Power bit. Then - assuming there is a spare 230v AC socket somewhere near where the ESP is going - plug in a 230v USB adapter to power the ESP. Any USB charging adaptor from an old phone will do, you only need fractions of an amp for an ESP.  And/or you can change the socket for one of those with builtin USB ports, then the socket stays available for whatever you use it for.

 

My octopus signup link https://share.octopus.energy/ebony-deer-230
210m2 house, Samsung 16kw Gen6 ASHP Self installed: Single circulation loop , PWM modulating pump.
My public ASHP stats: https://heatpumpmonitor.org/system/view?id=45
11.9kWp of PV
41kWh of Battery storage (3x Powerwall 2)
2x BEVs


   
ReplyQuote



(@iancalderbank)
Noble Member Contributor
Joined: 3 years ago
Posts: 643
 

Posted by: @cathoderay

I am now also wondering whether PoE is such a good idea after all. I do have a mains supply in the airing cupboard (supplies the remote wireless thermostat receiver, and powers the radiator circulating pump). It's currently a switched fused supply, no 13A socket, but I am sure I can get power from it without burning the house down. A 13A to low voltage DC power supply unit could then supply all the power needs, more simply and probably more cheaply, than using PoE. I still favour wired data connections though, old habits are slow to die! 

posts crossed.

if you are electrically competent, take a spur off the supply and wire up a 13A socket using one of these 

if you're not, get an electrician to do it.

plug the ESP into the USB port on the socket. done.

 

My octopus signup link https://share.octopus.energy/ebony-deer-230
210m2 house, Samsung 16kw Gen6 ASHP Self installed: Single circulation loop , PWM modulating pump.
My public ASHP stats: https://heatpumpmonitor.org/system/view?id=45
11.9kWp of PV
41kWh of Battery storage (3x Powerwall 2)
2x BEVs


   
ReplyQuote
(@Anonymous 5046)
Active Member
Joined: 2 years ago
Posts: 10
 

@iancalderbank 

great summary!

what I may add from practise is that ESP32 is very sensitive about 5V/3.3V power quality, especially during booting time when there is huge demand for current in very short time and many power supplies fail to provide, despite they are labelled 1, 2 or even 5 Amps. Even had problems with modern laptop or pc with USB3.0 which for example makes programming difficult, I spent endless hours figuring out what is wrong, replacing power supply or adding some circuits (like capacitor on power line) helped a bit.

You will see the effect on the console as endless booting loop.

ESP8266 is much less demanding and much more forgiving... beasides it's cheaper 🙂 And like the approach right tool for the right job, reading temperature is nothing for ESP8266, then even less for ESP32.

This post was modified 2 years ago by Anonymous

   
👍
1
ReplyQuote
(@iancalderbank)
Noble Member Contributor
Joined: 3 years ago
Posts: 643
 

Posted by: @cathoderay

Posted by: @derek-m

How do you keep your heat pump running but not your PC when you have a power cut?

 

"A power cut, or any thing else that renders both the heat pump and HA out of action, will only mean the boost instruction won't happen. , meaning, I think, [T]he only potential malfunction, given a running heat pump and out of action HA for some other reason eg software crash, is the LWT adjustments won't happen, the heat pump will just run in normal weather comp mode." 

Apologies if this is a dup post but I don't think it is

Power cuts are not the issue. in that case nothing works, solution is only a) wait for electric company b) protect yourself with house batteries (not for this thread)

The issue to consider is this: if your automation systems based on HA, ESP's or anything like that,  are not working any more - does your heating still work ? albeit perhaps without the "optimisations".

Example  : you upgrade HA to latest version and half your custom integrations stop working because they all need upgrading too , and one of them doesn't have an easy / well defined upgrade method because its bleeding edge ...you have to ping the developer on forum or github ... etc etc... 

exactly this happened to me yesterday - not just hypothetical.

 

My octopus signup link https://share.octopus.energy/ebony-deer-230
210m2 house, Samsung 16kw Gen6 ASHP Self installed: Single circulation loop , PWM modulating pump.
My public ASHP stats: https://heatpumpmonitor.org/system/view?id=45
11.9kWp of PV
41kWh of Battery storage (3x Powerwall 2)
2x BEVs


   
ReplyQuote
(@william1066)
Reputable Member Member
Joined: 2 years ago
Posts: 206
 

Posted by: @iancalderbank

exactly this happened to me yesterday - not just hypothetical.

Yes, so at the point my heating is fully controlled by HA, then I will have to put in a second (non prod) environment, for sure.  Right now I only upgrade HA on the .4 or later releases each month, anyway, not that I would want anyone else to do that of course, I need people to test it first 🤣 


   
ReplyQuote
(@derek-m)
Illustrious Member Member
Joined: 4 years ago
Posts: 4428
 

Posted by: @william1066

Posted by: @iancalderbank

exactly this happened to me yesterday - not just hypothetical.

Yes, so at the point my heating is fully controlled by HA, then I will have to put in a second (non prod) environment, for sure.  Right now I only upgrade HA on the .4 or later releases each month, anyway, not that I would want anyone else to do that of course, I need people to test it first 🤣 

If you are using a system for control purposes, I would suggest not carrying out any form of upgrading unless it is absolutely necessary. Industrial control systems, once commissioned and optimised, are never upgraded unless it is to rectify a discovered flaw.

What's that saying? "If it's not broke, don't fix it" 😋 

 


   
ReplyQuote
(@derek-m)
Illustrious Member Member
Joined: 4 years ago
Posts: 4428
 

@cathoderay

A quick question. Is the ambient air temperature reading available in the Midea Cloud? What other variables are available in the cloud that are not being picked up by HA?


   
ReplyQuote



Page 9 / 31
Share:

Join Us!

Trusted Installers

Struggling to find a reliable heat pump installer? A poor installation can lead to inefficiencies and high running costs. We now connect homeowners with top-rated installers who deliver quality work and excellent service.

✅ Verified, trusted & experienced installers
✅ Nationwide coverage expanding
✅ Special offers available

👉 Find your installer now!

Latest Posts

Members Online

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