Testing new controls/monitoring for Midea Clone ASHP
Posted by: @bensonAh great! Sounds like this is something where I could potentially use the HA helpers again and I can indeed see SV1 in my list of 200 odd entities I can monitor (and on and off history which seems to tally up with our DHW reheat set times).
For what it is worth, here (with some background explanation of how the registers work) is how you read the bit value for the three port two way valve (SV1) in python, where 0 = space heating and and 1 = DHW heating. You won't need to do this if you already have a value for SV1, but here it is anyway, partly a write up for my own benefit (notes, notes, and then more notes!) but also for the benefit of anyone who wants to do this outside HA.
Most if not all of the modbus registers return (what you get when you read a register) an integer (whole number). For 16 bit unsigned (no negative numbers) registers, this integer will be in the range 0 to 65,535 [explanation: each bit can hold a 0 or a 1, so the range in binary format is 0000000000000000 (= 0 decimal) to 1111111111111111 (=65,535 decimal)].
In the simplest case, the integer will be what it says: if register 107 (the outside air temp) returns 15, then the outside air temp is 15°C. Decimal places are dealt with by multiplying to get an integer eg the actual flow rate is 1.33m^3/h, then it gets multiplied by 100 to make it a whole number (133, stored in register 139), which we then retrieve, and then divide by 100 to get the actual value (1.33).
Other registers are used in a different way. Each of the 16 bits in the register holds a separate 0 or 1 (eg off/on) for 16 different items. Think of the register as a table row of 16 cells, each containing 0 or 1, the binary number is all those noughts and ones expressed as a single binary number 16 characters long, which might look like this: 0001001001101000. Each one or zero is the binary (on or off) state of something. But it doesn't get sent as a binary number, it gets sent as the decimal equivalent, in this case 4712.
The position of the three port two way valve (SV1), where 0 = space heating and and 1 = DHW heating, is held in bit 4 of register 129. Let's say we read regiter 129, and it happens to return 4712. This (see preceding paragraph) is the decimal representation of the binary number 0001001001101000. Each of the zeros and ones represents something is on or off.
The position of SV1 is in bit 4, which is in position 5 counting from the right hand end. This on the face of it is counter-intuitive, but it does in fact make sense if you bear in mind:
(a) the numbering is zero based, ie bit 0 is in the first position, bit 1 is in the second position, bit 2 in the third, bit 3 in the fourth and so to bit 4 in the fifth position
(b) we count from the right because 'that is how numbers work', in that they are right justified. Think of how it works on a calculator or in a spreadsheet: each time you make a number bigger, it expands to the left. The smallest numbers (0, 1 etc) are on the right, the bigger parts of the number are on the left (eg the 9 in 9000 is on the left). Bit 0 will be the rightmost character, bit 1 in the second right-most character, and so on. Bit 4 will be in the 5th right-most character.
The code to do all this in python is commendably brief, but rather cryptic without the above explanation. Assuming register 129 returned 4712 stored in a variable named register_129):
valve_position = "{:016b}".format(register_129)[-5]
How this works:
.format(var) means format var to the format to the left of the dot, of which:
{} makes it a string (rather than a number, simplifies later processing)
:016 makes it 16 characters long, right padded with zeros
b makes it binary
and then
[-5] extracts the fifth character from the right (the minus signs says count from the right)
4712 (decimal) = 0001001001101000 (binary), of which the fifth character from the right, being the contents of bit 4, is 0. The heat pump is in space heating mode.
Note that to make this work, you have to record the valve position every minute, because typically (at least for me) DHW heating takes less than an hour. I have my DHW heating on a timer, to come on between 1300 and 1400. If the tank needs heating, it will start tank heating a few minutes past 1300, and typically reach the set DHW temp about 30 minutes later. Thus for the second half of the hour, the DHW is still on (in the timer sense) but the system has reverted to space heating (because the DHW has reached its set temp). You can then use If statements to allocate the energy in and out to space heating of DHW heating.
Midea 14kW (for now...) ASHP heating both building and DHW
@benson”Active State” reflects the current state of your heat pump. And indeed the state of the 3-way-valve SV1 is taken into account to get the state.
The current possible states are “inactive”, “heating”, “cooling”, “defrosting”, “dhw” and recently added, “idle”.
This idle state is set when the heat pump's internal 'Operation Mode' is on, but it could not be mapped to a real state like 'Heating' or 'DHW'. This happens for example when the heat pump is preparing for a DHW run, or in between two heating runs.
In my personal setup I created virtual energy meters in Home Assistant for each state. The virtual energy meters are updated when the state is equal to the name of the virtual meter. To elaborate: if the state is heating, the virtual meter “heatpump-heating” is updated with the current state of the real energy meter, so that at the end of the month I can perfectly see how much kWh is used for each state.
@cathoderay and @mosibi thanks. A bit to get my head around there- but yes that mostly makes sense. I must admit when I was using chatgbt to set up the helpers (which seem like a great feature btw) I was a bit lost with exactly what it was doing. The mistakes it made was actually the simple stuff like what I was actually asking the statistics helper to track, so sum, change etc. I think it set it up as sum whereas in fact I wanted change, to set up the COP gauge, for example.
@cathoderay Are registers accessed by the address indicated in Midea's Modbus mapping table ? Because I found the actual address is +1.
Midea MHCV10WD2N7 R290, 5.8kWp energy community solar power.
Posted by: @bensonI must admit when I was using chatgbt to set up the helpers (which seem like a great feature btw) I was a bit lost with exactly what it was doing. The mistakes it made was actually the simple stuff like what I was actually asking the statistics helper to track, so sum, change etc.
A bit of topic, but indeed chatgpt and other AI a-likes have this tendency. Imho at this point in time you should not trust the output and always verify it yourself. But that is basically what you should do with everything you read on the internet 🙂
Posted by: @cathoderayIf the tank needs heating, it will start tank heating a few minutes past 1300, and typically reach the set DHW temp about 30 minutes later.
I am doing almost the same as you and also noticed that it always takes a few minutes before the state is set to "DHW" (e.g. 3-way-valve SV1 is flipped). I did investigate it a bit further and discovered that the heat pump is preparing for the dhw run and that it exactly takes 3 or 4 minutes. That heat pump is also in the same state between heating runs, so I named it the 'Idle' state in our solution and that gave me some extra insight in what is currently happening. This is my current logic to define all the "Active State"
if (id(${devicename}_operating_mode).state != "OFF") {
if (id(${devicename}_load_output_run).state) {
// The heat pump is on
if (id(${devicename}_status_bit_1_defrosting).state) {
return {"Defrosting"};
} else if (id(${devicename}_load_output_sv1).state) {
return {"DHW"};
} else {
// Return the state from "Operating Mode", which can be Cooling or Heating
return id(${devicename}_operating_mode).state;
}
} else {
// The heat pumps operating mode is on (not OFF), but is not "Heating", "Cooling", or "DHW".
// In this case the heat pump is Idle, which is for example the case when it is preparing for a DHW
// run or between "Heating" sessions
return {"Idle"};
}
} else {
// The heat pump is off
return {"Inactive"};
}
Posted by: @bensonI must admit when I was using chatgbt to set up the helpers...I was a bit lost with exactly what it was doing.
This is one of the reasons why AI will be the death of us, you don't have to understand anything! In other words, it removes the human steps of learning, understanding and then doing. That's what we old folk did in the days before AI (and I still do), and we benefited enormously. Sure, it was harder work, but we got our rewards. The other problem with AI is that it is frequently wrong, and the problem is that a naive (to the subject under consideration) AI user won't spot the error. A simple example: I asked google (search, not AI, but you get the AI overview anyway now) what the correct torques were for standard brass bolts. I expected to get some links, which I would then assess for quality etc. Meanwhile google's AI came up with its own confident answer, only it was wrong, it give the torques for medium to high tensile steel! I only spotted that because I knew a bit about fastenings, and the grades google mentioned (8.8, 10.9) are the grades used for higher tensile steels.
@mosibi — it seems we are on the same hymn sheet over AI!
Posted by: @tasosAre registers accessed by the address indicated in Midea's Modbus mapping table ? Because I found the actual address is +1.
The mapping table I have is in the wired controller manual, and the Register address column actually has entries eg 100 (PLC40101) (something to do with how modbus counts, zero and one based counting? The 40 prefix says it is a holding register) and it may depend on how you access the registers (the module or code you use). I use a python module/package called minimalmodbus (which manages to live up to its name, it is easy to use) and using that, I enter the first number (100) to get the data in register 100 (PLC40101). Maybe other access methods use the (PLC40)101 number? I did check I was getting the right data, eg heat pump amps and volts are next door to each other (registers 118 and 119) and the values I got were the credible (and the same as shown on the wired controller display).
Posted by: @mosibialso noticed that it always takes a few minutes before the state is set to "DHW"
It goes through a routine with various short delays as it switches from one mode to another, described somewhere in the manual. I use SV1 position on its own, because that is what physically determines where the heat put out by the heat pump actually goes.
You have certainly handled the defrost behaviour better than I have! My code assumes the heat pump is still in space heating mode (because of the SV1 position) during a defrost and calculates the energy out as it always does, flow rate x delta t x specific heat capacity, which means when it defrosts, and the LWT falls below the RWT, delta t and so the energy out both go negative! But in a way that does reflect reality, the heat is flowing the wrong way, from the house to the heat pump, rather than the other way round, and so on that level, it does make sense, at least to me, eg if an hour that contains a defrost cycle put 8kWh of heat in, and then takes 2kWh of heat back again, then the net heat energy delivered is 6kWh.
Midea 14kW (for now...) ASHP heating both building and DHW
Posted by: @cathoderayThis is one of the reasons why AI will be the death of us, you don't have to understand anything! In other words, it removes the human steps of learning, understanding and then doing.
It has it's uses and there is no way I could have set the helpers up myself without any chatgbt input, or not quickly anyway- but yes I can see where you are coming from. If it can make life a bit easier, then perhaps not alway a bad thing. It's fantastic for proof reading emails, I have recently discovered...
A bit like homely really- it makes life easier for end user, and certainly the installer (thus take with a large pinch of salt when they are promoting I would say as they will be motivated at least in part by the time it saves them). It can however be error prone and effectively reduces the end users requirement to understand their ashp settings.
- 26 Forums
- 2,323 Topics
- 52.1 K Posts
- 447 Online
- 5,979 Members
Join Us!
Podcast Picks
Latest Posts
-
RE: Solar panels on side of house to heat water
@majordennisbloodnok Oh sorry, I didn’t see that prefer...
By Toodles , 8 minutes ago
-
RE: Electricity price predictions
@batpred I’m afraid that Rachel Reeves has slapped a ve...
By Toodles , 20 minutes ago
-
RE: Replacing my 18 month old Hitachi Yutaki ASHP
@toodles thinking is existing, or did I miss some think...
By Batpred , 26 minutes ago
-
RE: Help me keep the faith with my air source heat pump installation
Yesterday it was chilly and the cosy6 had a Cop of 4.3 ...
By AgentGeorge , 31 minutes ago
-
RE: Solar Power Output – Let’s Compare Generation Figures
@toodles Same here! This month 187kw.
By Andris , 59 minutes ago
-
RE: Grant Aerona circulation/system pump staying on
@mikefl thanks, so to check is your parameter 4200 set ...
By damonc , 1 hour ago
-
Are Water Companies Delivering Bricks?!
Please look away now if you don’t wish to lose several ...
By Toodles , 1 hour ago
-
RE: Hitachi Yutaki SCombi Heat Pump - Owners
OK, how do you know its reached the set temperature, an...
By JamesPa , 4 hours ago
-
@jamespa Ah, they do indeed do firmware updates very oc...
By Toodles , 6 hours ago
-
I’m trying to rule out a fault, could owners of above c...
By Unsure , 6 hours ago
-
RE: Help…my Nibe has faulted again.
Have you actually had a Nibe engineer in or just an ins...
By JamesPa , 6 hours ago
-
RE: Jokes and fun posts about heat pumps and renewables
And I thought I was the one with the taxi on speed dial...
By Majordennisbloodnok , 19 hours ago
-
RE: Heat Pump Training vs. Real-World Installation
Congratulations on passing the course. The observation...
By Max Abbey , 1 day ago
-
RE: A2A vs A2W: Which Heat Pump Would You Pick?
The problem I see with A2A (and I'm interested if there...
By Temperature_Gradient , 1 day ago
-
RE: British Gas vs Octopus Energy vs Heat Geek vs EDF vs Aira vs OVO vs EON.Next vs Boxt
@temperature_gradient I specifically explained to my po...
By Toodles , 1 day ago
-
RE: Grant Aerona Short Cycling
@damonc I was refering to the 'standard' energy sticker...
By MikeFl , 1 day ago
-
RE: Havenwise App Help & Forum Support – Get the Most from Your Heat Pump
@hcas where do I find Havenwise Support? On...
By Morgan , 1 day ago
-
RE: Should Our Water Circulation Pump Be Configured to Run All The Time?
We recently (Aug 25) had a Grant Aeorana 3 installed un...
By GA3_USR , 2 days ago
-
RE: Configuring third party dongle for Ecodan local control
Thanks, @sheriff-fatman. Happy for you to search any po...
By Majordennisbloodnok , 2 days ago
-
Thanks, @cathoderay. I was aware of some changes to ...
By Majordennisbloodnok , 2 days ago





