python-e3dc icon indicating copy to clipboard operation
python-e3dc copied to clipboard

Writing Value for EMS_EP_RESERVE

Open hismastersvoice opened this issue 2 years ago • 5 comments

I tried to write the value for Emergency-Power-Reserve via RSCP to my E3DC Reading the value works fine.

But if I try to write, I always get NULL back and the value don't change. Can anybody help me please? Thanks in advance.

I have found that this value is % of the installed batterie capacity, and it is given als float32 eg 25.00 etc.

def set_epr(self, ep_reserve=None, keepAlive=False):

    res = self.sendRequest(
        (
            "EMS_REQ_EP_RESERVE",
            "Container",
            [
                ("EMS_EP_RESERVE", "Float32", ep_reserve),
            ],
        ),
        keepAlive=keepAlive,
    )

hismastersvoice avatar Oct 16 '22 16:10 hismastersvoice

After several attempts I did it like that and it worked, setting EP Reserve to 1650 Wh:

from e3dc import E3DC

...

retval = e3dc.rscp.sendRequest(
        (
            "SE_REQ_SET_EP_RESERVE",
            "Container",
            [
                ("SE_PARAM_INDEX", "Uint32", 0),
                ("SE_PARAM_EP_RESERVE", "Float32", 0.0),
                ("SE_PARAM_EP_RESERVE_W", "Float32", 1650.0),
            ],
        )
    );

Idea borrowed from here: https://github.com/nischram/E3dcGui/blob/1ed3dc163287f7227b303e22d4ff20c650143ad0/Rscp/RscpSet.cpp#L105

Selaron avatar Oct 16 '22 21:10 Selaron

You are my hero ;) Work well.

Thanks.

hismastersvoice avatar Oct 20 '22 19:10 hismastersvoice

Only thing is that for some reason the new value does not update on the touch screen UI, but it actually works.

Selaron avatar Oct 21 '22 05:10 Selaron

@Selaron

I can confirm this. The display stays with the old value.

Also reading the set value was a bit difficult. You only get a % value, but this % is calculated by installed capacity and state of health of the batteries.

For me it work perfectly now.

hismastersvoice avatar Oct 21 '22 05:10 hismastersvoice

Using this you can get the Wh reserve setting:

retval = e3dc.rscp.sendRequest(
                ("SE_REQ_EP_RESERVE", "None", None),
    )[2][2][2];

The [2][2][2] extracts the value out of the tuple.

Selaron avatar Oct 21 '22 15:10 Selaron