Skip to content

Huawei EMMA: add curtailment - #32006

Open
andig wants to merge 2 commits into
masterfrom
feat/emma-curtail
Open

Huawei EMMA: add curtailment#32006
andig wants to merge 2 commits into
masterfrom
feat/emma-curtail

Conversation

@andig

@andig andig commented Jul 21, 2026

Copy link
Copy Markdown
Member

fixes #31959

Adds EEG §9 curtailment to the Huawei EMMA meter template. EMMA is the master gateway, so the limit has to be written to EMMA itself (unit ID 0) rather than to the underlying inverters. Its registers mirror the SUN2000 semantics, so this reuses the existing curtail/curtailed pattern with EMMA addresses.

  • curtail writes the feed-in percentage to register 40109 (gain 10) and switches register 40100 between mode 7 (power-limited grid connection, %) and mode 0 (unlimited) at 100%
  • curtailed reports curtailment unless mode is 0, or mode 7 at 100%
  • adds the curtail capability to the template

Register addresses and encodings are taken from the SmartHEMS V100R024C00 MODBUS Interface Definitions (section 3.1, "Limited feed-in"), attached to the issue. They have not been verified against hardware.

TODO

  • @linuxstony please confirm on your EMMA that curtailment engages and releases as expected, and that it does not conflict with EMMA's own control loop

🤖 Generated with Claude Code

@andig andig added devices Specific device support enhancement New feature or request labels Jul 21, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The curtail sequence’s switch case for 100% appears to nest set twice (set: { source: const ... set: { source: modbus ... }}), which likely doesn’t match the usual template schema and may need to be flattened to a single set block.
  • In the curtailed Go block, percent is declared as int but read with scale: 0.1, which may produce a non-integer value; consider either removing the scale and comparing the raw register value or changing the type/scale so they are consistent with the script’s percent == 100 check.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `curtail` sequence’s `switch` case for 100% appears to nest `set` twice (`set: { source: const ... set: { source: modbus ... }}`), which likely doesn’t match the usual template schema and may need to be flattened to a single `set` block.
- In the `curtailed` Go block, `percent` is declared as `int` but read with `scale: 0.1`, which may produce a non-integer value; consider either removing the scale and comparing the raw register value or changing the type/scale so they are consistent with the script’s `percent == 100` check.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@andig
andig force-pushed the feat/emma-curtail branch from e790f34 to eff6ba7 Compare July 21, 2026 11:34
Comment thread templates/definition/meter/huawei-emma.yaml Outdated
@andig andig added the waiting for feedback Suspended progress label Jul 21, 2026
@linuxstony

Copy link
Copy Markdown

Currently at work. I am gonna install a nightly instance when I come home and try to confirm what you need.

@CiNcH83

CiNcH83 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This won't be in the nightly until it is merged into master. So you either have to build yourself or have a maintainer execute a /build which you then only have to install.

Do you know how you want to test it? It is not super easy to test without a real controlbox or controlbox simulator. Alternatively you could try with the --curtail command.

@linuxstony

linuxstony commented Jul 21, 2026

Copy link
Copy Markdown

A build would be the best optíon for me.

It seems good intentions don't suffice.... building my own is out of the question (when there a howto around i would try to).
I am a user who can hang on tutorials or howtos to try to adapt kernels back then with Arch linux - but thats where my "coding" knowledge stops.

I thought this would be integrated into nightly or testing branch. Then I would have simply switched from the offical to testing and would have tried the controlbox-simluator or the curtail command. (F*** - I must be annoying as fuck to you guys ...)

@andig

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Build finished.

@linuxstony

Copy link
Copy Markdown

Build installed on a separate pi - controlbox installed and running as well.
Will conduct the testing today after work. I am on it.

@linuxstony

linuxstony commented Jul 22, 2026

Copy link
Copy Markdown

I was able to limit the consumption but i could not limit the feed in - i could only forbid the feed in.

it stayed on for the duration i entered (2 minutes) and was never overridden by EMMA.
ksnip_20260722-192057
ksnip_20260722-192229
ksnip_20260722-192754
ksnip_20260722-192813
ksnip_20260722-194155
ksnip_20260722-194055
ksnip_20260722-193842

I am not that familiar with controlbox so it may be, that the limitation of the feed in works if I use the controlbox correctly.
If you want me to enter different values please tell me and I will do.

@CiNcH83

CiNcH83 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Can you post a screenshot of the controlbox?

image

The above sets feed-in limit to 2000 W.

Don't forget to set nominal max in HEMS:

image

This is in fact not the generator power but the max. AC power of the inverter. Otherwise the percent conversion is wrong for Huawei.

@linuxstony

Copy link
Copy Markdown

@CiNcH83 with those values there is no indication in evcc that anything is limited. However the sun is not shining atm - so i dont know if evcc only shows indications when it really has to act accordingly?

grafik No change with failsafe at zero or not.

@CiNcH83

CiNcH83 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Did you set nominal max?

@linuxstony

Copy link
Copy Markdown

no - i think that was transfered by evcc after I corrected my 8550 to 8800 as in your screenshot as I have a 8k-map0 with a "scheinleistung" wiht 8800VA.

@CiNcH83

CiNcH83 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

I also have an 8KTL. 8800W is correct for max. active power (=reactive power at power factor 1.0).

@linuxstony

Copy link
Copy Markdown

I switched to my productive system yesterday evening when the sun was down and I think i set the limits to zero (now i know that I have to clear the flieds to remove the limitation)

I realized that EMMA didnt allow production from the HUAWEI-Inverter so I fired up the 32006-build.

No indication of a limitation in the UI or backend. But EMMA definitely didnt produce (the production you see there is my mini-PV (Balkonkraftwerk) which is measured by the EMMA as well.

After I removed the limit at 09:10 you can see EMMA removing the limit.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devices Specific device support enhancement New feature or request waiting for feedback Suspended progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support grid power limiting (Drosselung / §14a) for Huawei EMMA

3 participants