I have been looking in detail at the code within various routines, in particular those associated with AC. Unfortunately it is not just a matter of copying over the code, and changing the AC references to C3. There also does not appear to have been a consistent approach carried out in the production of the different routines, which makes it all the more difficult to follow the logic.
Posted by: @derek-mMaybe try adding Byte23, Byte24 and Byte25 in the same manner as outdoor_temperature.
Back in January, I did something similar, in effect getting the data from these bytes. Here are the notes I made at the time:
data_offset + 16 = 5
data_offset + 15 = 25
data_offset + 14 = 25
data_offset + 22 = 0
data_offset + 23 = 128
24 device stops working
25 device stops working
30 device stops working
By 'device stops working' I think I meant it failed to load (fatal error). I concluded at that time there was no data beyond data_offset + 23. As the current code assigns the data from data_offset + 22 to outdoor_temperature, and it gets '0', it in effect confirms the above.
Meanwhile there has been a response overnight on github from the second midea_ac_lan, wasilukm:
"Hi, thank you for all the feedback. I don't know the other values you have mentioned. This all was reverse engineering.
I'm not planning to invest more time in this solution as I'm now using direct Modbus communication, which has documentation for all the data/registers. Not to mention it is more reliable."
I think one problem may be that the developer isn't familiar with heat pumps, and so LWT/RWT and flow rate, which were the other values mentioned. It also seems that he has come to pretty much the same conclusion that I was getting to at the end of last week, that it is time to try the modbus approach. which by his account is better documented (I think we can agree with that) and more reliable (I suspect it will be).
I did order the basic hardware at the end of last week, an RS-485 to USB converter, enough shielded twisted pair cable (actually shielded cat 5e ethernet cable) to cover the distance between the wired controller and the mini PC and some 120 ohm resistors that should be sufficient to put together a proof of concept setup. If that works, then I will put together something more permanent.
Midea 14kW (for now...) ASHP heating both building and DHW
When you carried out the previous test that you mentioned in your previous post, was the additional devices added within the byte array or outside?
Posted by: @derek-mWhen you carried out the previous test that you mentioned in your previous post, was the additional devices added within the byte array or outside?
Not in the def _body(self) code that has return bytearray(), just in the usual places to get the sensors added and message processed.
I've just been gong through this code from c3/message.py:
from ...core.message import ( MessageType, MessageRequest, MessageResponse, MessageBody, ) class MessageC3Base(MessageRequest): def __init__(self, device_protocol_version, message_type, body_type): super().__init__( device_protocol_version=device_protocol_version, device_type=0xC3, message_type=message_type, body_type=body_type ) @property def _body(self): raise NotImplementedError class MessageQuery(MessageC3Base): def __init__(self, device_protocol_version): super().__init__( device_protocol_version=device_protocol_version, message_type=MessageType.query, # this looks up MessageType > query in the imported core/message.py and returns 0x03, MessageType.notify1 would return 0x04 etc body_type=0x01) # body_type set here
and I can see how the query 'headers' are set up (the above sets up an 03/01 type message) but I am still lost as to how we can determine how to alter this (ie what numbers to use) to get other messages.
Midea 14kW (for now...) ASHP heating both building and DHW
I am fully aware of how the body type is selected.
Would you please carry out the proposed test, as suggested.
Posted by: @derek-mI am fully aware of how the body type is selected.
I'm sure you are, the above post was just adding more documentation for me and any others - if there are any - who may be following this thread.
Posted by: @derek-mWould you please carry out the proposed test, as suggested.
I am not sure which test this refers to:
Posted by: @derek-mMaybe try adding Byte23, Byte24 and Byte25 in the same manner as outdoor_temperature.
I have already in effect done that, see above. Anything above byte 23 breaks the code.
Posted by: @derek-mA further test would be to remove 'tank_actual_temperature' from the list and see if the data obtained is actually the tank temperature, but under the name outdoor_temperature.
I haven't done this because tank_actual_temperature is part of the live data collection, and I am reluctant to disrupt it.
Posted by: @derek-mA further test would be to move one of the energy devices to position 23, 24, 25 and 26 in the message body and see if it appears in the type 01 message.
I am not sure what an 'energy device' is or how to set positions in the message body. On the basis of what I think you mean, I have added this to the end of class C3MessageBody(MessageBody) (and commented out outdoor_temperature as it overlaps the bytes used) in c3/message.py:
self.tank_actual_temperature = body[data_offset + 21] # self.outdoor_temperature = body[data_offset + 22] # Add self.total_energy_consumption = ( (body[data_offset + 22] << 32) + (body[data_offset + 23] << 16) + (body[data_offset + 24] << 8) + (body[data_offset + 25])) class C3Notify1MessageBody(MessageBody):
This time, the inclusion of bytes above 23 didn't break the code totally ie it loads, but what I get in the log entry is:
2023-03-13 13:07:40.422 ERROR (Heat Pump (LAN)) [custom_components.midea_ac_lan.midea.core.device] [device_id] Unknown error IndexError('index out of range')
2023-03-13 13:07:40.827 DEBUG (Heat Pump (LAN)) [custom_components.midea_ac_lan.midea.core.device] [device_id] Status update: {'available': False}
and then it gives up the ghost, endless handshaking followed by the above:
Connected
Handshaking
Authentication success
Sending: {'header': 'aa0bc300000000000003', 'body': '01', 'message type': '03', etc etc
Unknown error IndexError('index out of range')
Status update: {'available': False}
repeated over and over.
I suspect "IndexError('index out of range')" may be because bytes above 23 don't exist, so we get a typical index out of range error.
Midea 14kW (for now...) ASHP heating both building and DHW
The objective was to see if the message body could be extended to incorporate new data. If I am interpreting the result correctly, this was achieved. The errors being generated could be because additional code has not be added in other routines. Please provide a text copy of the relevant files, so that I can see what you have done. I am rather busy at the moment so I will have a look later. Could you also provide a copy of the message body string after each test.
Posted by: @derek-mThe objective was to see if the message body could be extended to incorporate new data. If I am interpreting the result correctly, this was achieved.
Not really, what you see above is what you get, no message body or string at all. I've seen this before. The code can either fail to load at all, there is usually just a line or two in the log saying fatal error, or it will load and do handshaking and then fail. This is what is happening this time, and it gets stuck in an endless handshaking fail handshaking fail loop. My reading is the 'index out of range' error is the clue, I've seen this when an array is supposed to have x members, when in fact it has x + n members, and the error happens when a loop acting on the array tries to operate on a member that is out of the expected range.
The only code change I made is the one I posted above, adding the energy entity with the higher byte numbers (and commenting out outdoor_temperature because of the byte overlap). I can send the whole lot again, but I for one find tracking version changes a nightmare, so I try to keep the number of files as small as possible.
No problem at all with the time scale, we all have other things to do!
Midea 14kW (for now...) ASHP heating both building and DHW
Posted by: @cathoderayPosted by: @derek-mThe objective was to see if the message body could be extended to incorporate new data. If I am interpreting the result correctly, this was achieved.
Not really, what you see above is what you get, no message body or string at all. I've seen this before. The code can either fail to load at all, there is usually just a line or two in the log saying fatal error, or it will load and do handshaking and then fail. This is what is happening this time, and it gets stuck in an endless handshaking fail handshaking fail loop. My reading is the 'index out of range' error is the clue, I've seen this when an array is supposed to have x members, when in fact it has x + n members, and the error happens when a loop acting on the array tries to operate on a member that is out of the expected range.
The only code change I made is the one I posted above, adding the energy entity with the higher byte numbers (and commenting out outdoor_temperature because of the byte overlap). I can send the whole lot again, but I for one find tracking version changes a nightmare, so I try to keep the number of files as small as possible.
No problem at all with the time scale, we all have other things to do!
I would suggest that you remove recent added code until you once more obtain a message, and then let me know what code has been removed, from where. Also post a copy of the message.
Posted by: @derek-mI would suggest that you remove recent added code until you once more obtain a message, and then let me know what code has been removed, from where.
I removed the code causing the error straight away, and the remaining code now functions normally as it did before. The code added and then removed is exactly as shown above in my 1:17pm post: added # at the start of the self.outdoor_temperature line and then added the five total_energy lines immediately below. Removal reversed those changes.
Midea 14kW (for now...) ASHP heating both building and DHW
Posted by: @cathoderayPosted by: @derek-mI would suggest that you remove recent added code until you once more obtain a message, and then let me know what code has been removed, from where.
I removed the code causing the error straight away, and the remaining code now functions normally as it did before. The code added and then removed is exactly as shown above in my 1:17pm post: added # at the start of the self.outdoor_temperature line and then added the five total_energy lines immediately below. Removal reversed those changes.
Can you now post a copy of the message.
Can you provide a text copy of midea/core/message.py
- 21 Forums
- 1,964 Topics
- 42.6 K Posts
- 28 Online
- 2,278 Members
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)
Latest Posts
-
RE: Newbie out of her depth – Samsung AE120RXYDEG 12kW heat pump
@bami yes. 8kw = 8000w I would change the areas in th...
By bontwoody , 3 minutes ago
-
RE: Towel rails. An unexpected final hurdle
I had a similar issue but convinced the installer to le...
By Pie_Eater , 45 minutes ago
-
Cliff, welcome to the forum. You’re running into one ...
By Mars , 53 minutes ago
-
RE: What is the best strategy for operating a very oversized heat pump?
This whole discussion highlights just how much of a mes...
By Mars , 1 hour ago
-
RE: NIBE F2040 12 kW heat pump and 100 liter buffer tank
@cheshirejohn thanks for the update and for sharing. I’...
By Mars , 1 hour ago
-
RE: Setback savings - fact or fiction?
Here's the same plot, less the R squared values, done q...
By cathodeRay , 4 hours ago
-
RE: SolarPV tables / online calculator
We've only had our solar since last June, but so far fo...
By Old_Scientist , 4 hours ago
-
@robs useful thread! Thanks for sharing - Octopus are c...
By big_si , 4 hours ago
-
RE: Volumisers in Heat Pump Systems: Does Placement Matter?
@jamespa Agreed. I think it’s a case of much over muchn...
By Mars , 6 hours ago
-
@eliuccio Unfortunately, whilst I agree with a lot of...
By JamesPa , 7 hours ago
-
RE: Samsung Gen 7 R290 12kW is not behaving how I expected
Definitely its in the 20xx FSVs. Conversely it may be...
By JamesPa , 8 hours ago
-
RE: Heat Pump Sizing & Installation Costs
Perhaps useful to have installed date too? To get conte...
By Tim441 , 12 hours ago
-
RE: F.788 Building circuit pump reports internal fault - Vaillant Arotherm
Guess I have to wait for engineer visit. I really hope ...
By jeegnesh , 1 day ago
-
RE: Act now to defer the UK road tax increase on EVs
@majordennisbloodnok Damn right sir. my attempt at iron...
By Jancold , 1 day ago
-
RE: ASHP and heating issues in new build house
That’s good gives you more capacity. It made me think, ...
By Terry1812 , 1 day ago
-
RE: Seewet manhole cover within r290 exclusion zone
Thanks! I asked Vaillant, and they say I should be fi...
By dbrb2 , 1 day ago
-
Looking for the Grant Aerona 3 setting to turn off completely at 20 OAT
I'm running my Aerona 3 on WC and the 'warm end of that...
By damonc , 1 day ago
-
RE: Do I just go with the lowest quote for my heat pump?
So after signing in Sept in two weeks the install may s...
By Jancold , 1 day ago
-
RE: Victorian Semi Retrofit / Extension ASHP and UFH Advice
When you are renovating is always a good time, as it ma...
By JamesPa , 2 days ago
Latest Topics
-
By cliffhanger 1 hour ago
-
Heat Pump Sizing & Installation Costs
By Mars 14 hours ago
-
Volumisers in Heat Pump Systems: Does Placement Matter?
By Mars 15 hours ago
-
SolarPV tables / online calculator
By MichelleC 22 hours ago