# Change energy channel assignment based on meter type

**URL:** <https://community.openems.io/t/change-energy-channel-assignment-based-on-meter-type/1603>\
**Category:** English Forum\
**Created:** [May 22, 2023, 3:07pm UTC](https://community.openems.io/t/change-energy-channel-assignment-based-on-meter-type/1603 "2023-05-22T15:07:48Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![stefan.feilmeier](https://community.openems.io/user_avatar/community.openems.io/stefan.feilmeier/32/2585_2.png) [@stefan.feilmeier](https://community.openems.io/u/stefan.feilmeier)\
**Post date:** [May 29, 2023, 9:00pm UTC](https://community.openems.io/t/change-energy-channel-assignment-based-on-meter-type/1603/5 "2023-05-29T21:00:23Z")

</div>

HI Philipp,

Thanks for starting this discussion and for the in-depth analysis and explanation. It’s definitely true, that some things feel mixed up and implementations are not always consistent throughout the code. Clear and better definition of Channels will definitely help here.

To answer the question on how power flows are interpreted in OpenEMS, you are completely right. In [`SymmetricMeter`](https://github.com/OpenEMS/openems/blob/develop/io.openems.edge.meter.api/src/io/openems/edge/meter/api/SymmetricMeter.java#LL81C10-L81C10) we state _“Range: negative values for Consumption (power that is ‘leaving the system’, e.g. feed-to-grid); positive for Production (power that is ‘entering the system’)”_. This definition is unfortunately quite misleading (or even wrong) for meters that actually measure Consumption.

1. The idea for power flow was - just like you (and @tsicking in [#2159](https://github.com/OpenEMS/openems/pull/2159#issuecomment-1525617738)) described - to think ‘from the middle’. This can best be seen and followed in the [`_sum` calculations for Energy and Power](https://github.com/OpenEMS/openems/blob/develop/io.openems.edge.core/src/io/openems/edge/core/sum/SumImpl.java#L379-L396).

2. We always assumed positive `ActivePower` to relate with `ProductionActiveEnergy` and negative `ActivePower` to relate with `ConsumptionActiveEnergy`. See e.g. this calculation in GoodWeGridMeterImpl:

> <https://github.com/OpenEMS/openems/blob/develop/io.openems.edge.goodwe/src/io/openems/edge/goodwe/gridmeter/GoodWeGridMeterImpl.java#L176-L195>

This same approach is used also in the CONSUMPTION\_METERED [`GoodWeEmergencyPowerMeterImpl`](https://github.com/OpenEMS/openems/blob/develop/io.openems.edge.goodwe/src/io/openems/edge/goodwe/emergencypowermeter/GoodWeEmergencyPowerMeterImpl.java). Consequently in the UI History chart we also show [`ActiveProductionEnergy`](https://github.com/OpenEMS/openems/blob/develop/ui/src/app/edge/history/consumption/widget.component.ts#L85-L93) for consumption energy and not `ActiveConsumptionEnergy`.

Additionally as you found, for many meters we have a `invert` configuration option, that inverts `ActivePower` and should consequently also invert all related fields. But from your findings it seems this is not the case everywhere.

I understand that all of this is confusing; on the other side it is also currently working in production with thousands of systems. As you alread assumed, we are just using the ‘invert’ configuration in these cases to ‘fix’ consumption meters.

So as always, the complicated part is to improve the code (by refactoring or documentation) and still stay as backwards-compatible as possible. Especially as this issue relates also to historic data in a timeseries database we as FENECON and others who use this will have big issues fixing it.

From my point of view it could be sufficient to fix the `invert` configuration option in all meters and make it invert everything (Power, Current, Energy) and document in the READMEs, that if a meter is used as Consumption meter (and it is wired according to the manual), the `invert` configuration has to be set.

Additionally it might make sense to rename the Energy channels. I’ve read e.g. “ImportEnergy” and “ExportEnergy” in the past in Modbus protocols. Some research might help here to find a suitable name.

On the other side, if the Community agrees that a real proper solution would be to introduce a `isWiringDirectionReversed` configuration option everywhere, I will also support it. For the moment I am unsure on what the best solution is.

Regards,  
Stefan

---

_[View the full topic](https://community.openems.io/t/change-energy-channel-assignment-based-on-meter-type/1603)._
