frequenz-floss / frequenz-sdk-python

Frequenz Python Software Development Kit (SDK)
https://frequenz-floss.github.io/frequenz-sdk-python/
MIT License
13 stars 17 forks source link

In message received from `PvPool.power_status` target_power is None until someone set value to the microgrid #1118

Open ela-kotulska-frequenz opened 2 hours ago

ela-kotulska-frequenz commented 2 hours ago

What happened?

I would like to receive pv power on every update of pv power or its bounds.

I receive power status from pv_pool.power_status.new_receiver() but until I send pv_pool.propose_power, the target_power is None.

Also on every update pv status is send 2 times. I expect 1 message per update.

async def main():
    await initialize_microgrid()

    pv_pool = microgrid.new_pv_pool(priority=1)
    pv_power = pv_pool.power.new_receiver()
    pv_status = pv_pool.power_status.new_receiver()

    counter = 0
    async for selected in select(pv_power, pv_status):
        if selected_from(selected, pv_power):
            print(f"PV power: {selected.message.value}")
        elif selected_from(selected, pv_status):
            print(f"PV status: {selected.message}")

        counter += 1
        if counter % 10 == 0:
            await pv_pool.propose_power(Power.from_watts(-counter))

Logs:

PV status: _Report(target_power=None, _inclusion_bounds=Bounds(lower=Power(value=-30000.0, exponent=0), upper=Power(value=0.0, exponent=0)), _exclusion_bounds=Bounds(lower=Power(value=0.0, exponent=0), upper=Power(value=0.0, exponent=0)))
PV status: _Report(target_power=None, _inclusion_bounds=Bounds(lower=Power(value=-60000.0, exponent=0), upper=Power(value=0.0, exponent=0)), _exclusion_bounds=Bounds(lower=Power(value=0.0, exponent=0), upper=Power(value=0.0, exponent=0)))
PV power: -39 kW
PV power: -39 kW
PV power: -39 kW
PV power: -39 kW
PV power: -39 kW
PV power: -39 kW
PV power: -39 kW
PV power: -39 kW
PV status: _Report(target_power=Power(value=-10.0, exponent=0), _inclusion_bounds=Bounds(lower=Power(value=-60000.0, exponent=0), upper=Power(value=0.0, exponent=0)), _exclusion_bounds=Bounds(lower=Power(value=0.0, exponent=0), upper=Power(value=0.0, exponent=0)))
PV status: _Report(target_power=Power(value=-10.0, exponent=0), _inclusion_bounds=Bounds(lower=Power(value=-60000.0, exponent=0), upper=Power(value=0.0, exponent=0)), _exclusion_bounds=Bounds(lower=Power(value=0.0, exponent=0), upper=Power(value=0.0, exponent=0)))

What did you expect instead?

Affected version(s)

v1.0.0-rc1200, v1.0.0-rc1300,

Affected part(s)

Microgrid (API, component graph, etc.) (part:microgrid)

Extra information

No response

shsms commented 2 hours ago

target_power is the power we want to set, not the measured power. So, I think the behaviour is correct. But maybe we can make it easier to understand.

shsms commented 2 hours ago

Also on every update pv status is send 2 times. I expect 1 message per update.

This is also a known issue, just hasn't been prioritized: https://github.com/frequenz-floss/frequenz-sdk-python/issues/818#issuecomment-2203358082