enbility / cemd

Energy management system using the EEBUS protocol
https://enbility.net
MIT License
13 stars 7 forks source link

CEM: simplify event handlers #23

Closed andig closed 8 months ago

andig commented 8 months ago

Creating CEM UCs requires

type EventHandlerCB func(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event EventType)

Given that spineapi.EntityRemoteInterface includes Device() it seems the device parameter is not necessary? Same should apply to SKI via device?

DerAndereAndi commented 8 months ago

I don't think this is good, as an EV disconnect has to report the Entity that was disconnected. But as the entity is no longer connected, it has lost the relation to the Device. So you can't get the SKI any longer that way.

In addition there are messages that don't have an Entity set, e.g. if the wallbox was connected or disconnected (offline).

For now I would like to keep it as it is.

DerAndereAndi commented 8 months ago

The event handlers have been changed a bit, also based on your suggestions. See https://github.com/enbility/cemd/commit/d46d7436de874166307557b28fa7a8968fb18a74