fsantini / python-e3dc

Python API for querying E3/DC systems through the manufacturer's portal
MIT License
71 stars 23 forks source link

Writing Value for EMS_EP_RESERVE #68

Open hismastersvoice opened 1 year ago

hismastersvoice commented 1 year ago

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,
    )
Selaron commented 1 year ago

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

hismastersvoice commented 1 year ago

You are my hero ;) Work well.

Thanks.

Selaron commented 1 year ago

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

hismastersvoice commented 1 year ago

@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.

Selaron commented 1 year ago

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.