suaveolent / hoymiles-wifi

Library to communicate with Hoymiles DTUs and HMS-XXXXW-2T microinverters via protobuf.
MIT License
49 stars 10 forks source link

AC output always 0 on Home Assistant #13

Closed elafontaine closed 4 months ago

elafontaine commented 4 months ago

Is your feature request related to a problem? Please describe. I get a 0 for the AC output energy in home assistant, but I know it's because the sgs_data is missing a field. How could I help find which one and be able to make it available ? Describe the solution you'd like Able to get an inverter view of the power put back on AC. And the same from the DTU.

Describe alternatives you've considered Preparing a metric based on the PV_DATA, but that would not consider loss I believe.

Additional context Here is the output I get:

> hoymiles-wifi.exe --host "192.168.2.x" get-real-data-new 
Get-real-data-new Response: 
device_serial_number: <REDACTED>
timestamp: 1716314958
active_power: 1
firmware_version: 1
sgs_data {
  serial_number: <REDACTED>
  firmware_version: 1
  voltage: 2449
  frequency: 6000
  active_power: 7499
  reactive_power: -1
  current: 306
  power_factor: 1
  temperature: 373
  warning_number: 1
  crc_checksum: 63022
  link_status: 1
  modulation_index_signal: 393222
}
sgs_data {
  serial_number: <REDACTED>
  firmware_version: 1
  voltage: 2451
  frequency: 6002
  active_power: 7982
  reactive_power: -1
  current: 325
  power_factor: 1
  temperature: 376
  warning_number: 1
  crc_checksum: 6600
  link_status: 1
  modulation_index_signal: 6029401
}
pv_data {
  serial_number: <REDACTED>
  port_number: 1
  voltage: 400
  current: 499
  power: 2001
  energy_total: 41710
  energy_daily: 1007
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 2
  voltage: 407
  current: 482
  power: 1965
  energy_total: 38441
  energy_daily: 904
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 3
  voltage: 400
  current: 495
  power: 1982
  energy_total: 40464
  energy_daily: 997
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 4
  voltage: 399
  current: 486
  power: 1944
  energy_total: 40053
  energy_daily: 977
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 1
  voltage: 404
  current: 536
  power: 2171
  energy_total: 43979
  energy_daily: 1072
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 2
  voltage: 400
  current: 521
  power: 2089
  energy_total: 42503
  energy_daily: 1019
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 3
  voltage: 404
  current: 507
  power: 2055
  energy_total: 39964
  energy_daily: 917
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 4
  voltage: 399
  current: 522
  power: 2086
  energy_total: 42357
  energy_daily: 1016
  error_code: 50331648
}
suaveolent commented 4 months ago

Actually, AC output should not be 0 for you.

I am using the active_power field of sgs_data. For the response you posted this should be: 7499 and 7982.

Is everything else working and are you running the latest version of the integration?

suaveolent commented 4 months ago

Update: I change the value in some version to directly use the inverters AC output instead of the DTU, so that multiple inverters are supported.

The sensor you are referring might be a sensor which is not provided any more and needs to be manually removed (if you updated from a previous version)

The AC output can now be found in every Inverter separately. Maybe that fixes your problem?

elafontaine commented 4 months ago

Ok, yes, I do get the AC Power output from each inverter, but I thought this would have been the AC energy (my bad). The reason I was hoping for the AC daily energy was that I hoped to see how much was returned from all my inverters into the grid.

Also, I guess that the AC power in there is not in W, but something like deci-W.

Before I close this issue (not a real issue), do you know if we could get the sensor of "DTU's daily energy" from all the connected inverters ? I would be ready to look into it in my free time.

suaveolent commented 4 months ago

Yes, this should be possible with the app-get-hist-power command. It reports DTU total_energy and daily_energy. I have been wanting to implement but did not yet find the time to do so.

The AC power reported in the integration is already converted to Watts. So nothing to do on your side. However, you can change the unit by clicking on the sensor, then on the gear icon and then on the "Unit of measurement".

elafontaine commented 4 months ago

hum... I get this when I run the app-get-hist-power;

(venv) PS C:\Users\erlafont\PycharmProjects\noip-automation> hoymiles-wifi.exe --host <REDACTED> app-get-hist-power
No response or unable to retrieve response for app-get-hist-power
elafontaine commented 4 months ago

also, this is weird, but I think there might be something else at play here. Notice the last pv data AND the 2nd inverter doesn't give me all the fields...;

(venv) PS C:\Users\erlafont\PycharmProjects\noip-automation> hoymiles-wifi.exe --host "192.168.2.214" get-real-data-new 
Get-real-data-new Response: 
device_serial_number: <REDACTED>
timestamp: 1716999137
active_power: 1
firmware_version: 1
sgs_data {
  serial_number: <REDACTED>
  firmware_version: 1
  voltage: 2423
  frequency: 5995
  active_power: 16206
  reactive_power: -1
  current: 668
  power_factor: 1
  temperature: 517
  crc_checksum: 58842
  link_status: 1
  modulation_index_signal: 2883627
}
sgs_data {
  serial_number: <REDACTED>
  firmware_version: 1
  crc_checksum: 48261
  modulation_index_signal: 262148
}
pv_data {
  serial_number: <REDACTED>
  port_number: 1
  voltage: 392
  current: 1085
  power: 4254
  energy_total: 62638
  energy_daily: 1089
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 2
  voltage: 393
  current: 1084
  power: 4266
  energy_total: 57836
  energy_daily: 806
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 3
  voltage: 391
  current: 1090
  power: 4271
  energy_total: 61291
  energy_daily: 1087
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 4
  voltage: 390
  current: 1092
  power: 4267
  energy_total: 60653
  energy_daily: 1073
  error_code: 50331648
}
pv_data {
  serial_number: <REDACTED>
  port_number: 1
  voltage: 396
  current: 1107
  power: 4387
  energy_total: 65854
  energy_daily: 1137
}
pv_data {
  serial_number: <REDACTED>
  port_number: 2
  voltage: 393
  current: 1080
  power: 4244
  energy_total: 63655
  energy_daily: 1085
}
pv_data {
  serial_number: <REDACTED>
  port_number: 3
  voltage: 395
  current: 1075
  power: 4251
  energy_total: 59508
}
pv_data {
  serial_number: <REDACTED>
  port_number: 4
  voltage: 390
  current: 1089
  power: 4255
}
suaveolent commented 4 months ago

hum... I get this when I run the app-get-hist-power;

(venv) PS C:\Users\erlafont\PycharmProjects\noip-automation> hoymiles-wifi.exe --host <REDACTED> app-get-hist-power
No response or unable to retrieve response for app-get-hist-power

Hm that is weird indeed. Can you directly connect to your DTU via the App and check if the app is able to retrieve the data? If so, can you maybe log the request via Wireshark?

elafontaine commented 4 months ago

ok, Maybe, big maybe, this happens when the inverter is down ?

There is another ticket I opened about the microinverters having a weird behaviour on metrics when they went down. I noticed in my output above that the error_code is only present on the first 4 and not present on the last 4 (I have 2x 4-in-1 micro-inverters).

Tonight, I got all the output, but the error_code field is there. My panels aren't generating enough energy to maintain the micro-inverter for long (which I believe is why I see both inverter getting the same error_code value).

I'm going to try to understand this protobuf and how they came to find that... but I believe it may be wrongly setup and not representing big-endianness of some values and could explain some of the weirdness I observe.

Do you know if this is modprobe over TCP on port 10081 ? I would like some confirmation, that way, it could help me understand why this protobuf stuff is working...

elafontaine commented 4 months ago

Ok, Noticing that the inverters got detected as HMS-1600-4T and not as HMS-2000-4T like I have... not sure if it's relevant.

elafontaine commented 4 months ago

The DTU was identified as DTU-PRO, but I got a DTU-Pro-S and my serial number starts with 0x10FD 0x10FD: DTUType.DTU_PRO, ==> should probably be changed to DTU-Pro-S unless you know why it's wasn't already (and maybe it's not being respected by hoymiles?)

Same for the power of the micro-inverter, I figured out that the serial number in hex (from the int) gives me this entry ; 0x1164: InverterPower.P_1600,

elafontaine commented 4 months ago

As mentionned in the other ticket, I thought I had the latest version of the DTU software version, turns out I was wrong and that updating it solved part of the issue. Now, I believe this is linked to when I lose a micro-inverter, the metric becomes screwed and I have only half the value until the next day when I get a data point. (this is why it doesn't go all the way down and still to half the value all through the night).

image

elafontaine commented 4 months ago

Problem seems to be linked to this now ; https://github.com/suaveolent/ha-hoymiles-wifi/issues/39