ElectricityMeter General Question

Hello,

The Production is shown as “Consumption” but in fact there is no “Consumption-Meter” there, so it should be sent to grid instead on the UI…

This is my Impl. so far, where i handle if the inverter is only a String-Inverter without a Battery:

@Designate(ocd = Config.class, factory = true)
@Component(//
        name = "String-Inverter.Sungrow", //
        immediate = true, //
        configurationPolicy = ConfigurationPolicy.REQUIRE //
)
public class SungrowStringInverterImpl extends AbstractOpenemsModbusComponent implements
        ElectricityMeter, SungrowStringInverter, ModbusComponent, OpenemsComponent {

    public SungrowStringInverterImpl() {
        super(//
                OpenemsComponent.ChannelId.values(), //
                ModbusComponent.ChannelId.values(), //
                ManagedSymmetricPvInverter.ChannelId.values(), //
                ElectricityMeter.ChannelId.values(), //
                SungrowStringInverter.ChannelId.values() //
        );
    }
    

    @Reference
    protected ConfigurationAdmin cm;
    private Sum sum;


    @Reference(policy = ReferencePolicy.STATIC, policyOption = ReferencePolicyOption.GREEDY, cardinality = ReferenceCardinality.MANDATORY)
    protected void setModbus(BridgeModbus modbus) {
        super.setModbus(modbus);
    }
    
    private MeterType meterType = MeterType.GRID;

    private boolean invertActivePower;

    
    @Activate
    void activate(ComponentContext context, Config config) throws OpenemsException {    	
        this.meterType = config.type();
        this.invertActivePower = config.invertActivePower();
        if (super.activate(context, config.id(), config.alias(), config.enabled(), config.modbusUnitId(), this.cm,
                "Modbus", config.modbus_id())) {
            return;
        }
    }
    

    @Deactivate
    protected void deactivate() {
        super.deactivate();
    }

    @Override
    protected ModbusProtocol defineModbusProtocol() throws OpenemsException {
        ElementToChannelConverter converter = this.invertActivePower ? ElementToChannelConverter.INVERT : ElementToChannelConverter.DIRECT_1_TO_1;

        return new ModbusProtocol(this, new FC4ReadInputRegistersTask(4989, Priority.HIGH,
                m(SungrowStringInverter.ChannelId.SERIAL_NUMBER, new StringWordElement(4989, 10)),
                new DummyRegisterElement(4999, 5017),
        		m(ElectricityMeter.ChannelId.VOLTAGE_L1, new UnsignedWordElement(5018), //
        				ElementToChannelConverter.SCALE_FACTOR_2), //
        		m(ElectricityMeter.ChannelId.VOLTAGE_L2, new UnsignedWordElement(5019), //
        				ElementToChannelConverter.SCALE_FACTOR_2), //
        		m(ElectricityMeter.ChannelId.VOLTAGE_L3, new UnsignedWordElement(5020), //
        				ElementToChannelConverter.SCALE_FACTOR_2), //
        		m(ElectricityMeter.ChannelId.CURRENT_L1, new UnsignedWordElement(5021), //
        				ElementToChannelConverter.SCALE_FACTOR_2), //
        		m(ElectricityMeter.ChannelId.CURRENT_L2, new UnsignedWordElement(5022), //
        				ElementToChannelConverter.SCALE_FACTOR_2), //
        		m(ElectricityMeter.ChannelId.CURRENT_L3, new UnsignedWordElement(5023), //
        				ElementToChannelConverter.SCALE_FACTOR_2), //
                new DummyRegisterElement(5024, 5029),
                m(ElectricityMeter.ChannelId.ACTIVE_POWER,
                        new UnsignedDoublewordElement(5030).wordOrder(WordOrder.LSWMSW), converter)
                
                
        ));
    }

    @Override
    public String debugLog() {
        return "L:" + this.getActivePower().asString();
    }

	@Override
	public MeterType getMeterType() {
		return this.meterType;
	}
}

How do i fix this?

For future readers: this was answered here:

Hello Stefan,

i see i have a new “Problem” now. The meter shows no correct values from time to time it sporadically jumps up and down regarding tge values. See the attached Picture :slight_smile:

I added tge Virtual Meter as you said as a component :slight_smile:

What could it be?

Hi. Good question. I can’t quite explain this behaviour myself (without much more information and your detailed config and code)… sorry.

1 Like