enbility / eebus-go

EEBUS protocol implementation in go
https://enbility.net
MIT License
52 stars 14 forks source link

Adjusting public methods arguments to support JSON-RPC #92

Open DerAndereAndi opened 2 months ago

DerAndereAndi commented 2 months ago

Right now the public methods arguments require an argument entity spineapi.EntityRemoteInterface to specify which entity of which remote device is meant. This can not be used / represented via JSON.

To make this work, the idea would be to use an SPINE model.EntityAddressType similar data type. The SPINE data definition is:

type EntityAddressType struct {
    Device *AddressDeviceType  `json:"device,omitempty"`
    Entity []AddressEntityType `json:"entity,omitempty"`
}

A compatible and easier to use data type would be:

type EntityAddressType struct {
    Device string
    Entity []uint
}

This can be easily represented in JSON and also used to get the corresponding entity spineapi.EntityRemoteInterface which is needed to invoke the functions. The data structure can also be easily created in the callback functions from an entity spineapi.EntityRemoteInterface data type using a generic helper method.

DerAndereAndi commented 4 days ago

This wouldn't be enough, as each exported method needs to have a second pointer variable for the response. Which in turn would change how everything works.