diff --git a/controlbox.go b/controlbox.go index 0ced3d2..0a40074 100644 --- a/controlbox.go +++ b/controlbox.go @@ -318,6 +318,10 @@ func (h *controlbox) readConsumptionNominalMax(entity spineapi.EntityRemoteInter } func (h *controlbox) OnLPCEvent(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) { + if entity == nil { + return + } + fmt.Println("--> LPC Event: " + string(event) + " from " + ski) connected, exists := h.isConnected[ski] if !exists || !connected { @@ -434,6 +438,10 @@ func (h *controlbox) readProductionNominalMax(entity spineapi.EntityRemoteInterf } func (h *controlbox) OnLPPEvent(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) { + if entity == nil { + return + } + fmt.Println("--> LPP Event: " + string(event) + " from " + ski) connected, exists := h.isConnected[ski] if !exists || !connected { @@ -504,6 +512,10 @@ func (h *controlbox) OnLPPEvent(ski string, device spineapi.DeviceRemoteInterfac } func (h *controlbox) OnMGCPEvent(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) { + if entity == nil { + return + } + fmt.Println("--> MGCP Event: " + string(event) + " from " + ski) connected, exists := h.isConnected[ski] if !exists || !connected { @@ -555,6 +567,10 @@ func (h *controlbox) OnMGCPEvent(ski string, device spineapi.DeviceRemoteInterfa } func (h *controlbox) OnMPCEvent(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) { + if entity == nil { + return + } + fmt.Println("--> MPC Event: " + string(event) + " from " + ski) connected, exists := h.isConnected[ski] if !exists || !connected { diff --git a/frontend.go b/frontend.go index 3c71cf0..cacf023 100644 --- a/frontend.go +++ b/frontend.go @@ -92,6 +92,10 @@ type Message struct { } func readData(h *controlbox, entity spineapi.EntityRemoteInterface, ucs []string) { + if entity == nil || entity.Device() == nil { + return + } + ski := entity.Device().Ski() if (ucs == nil || slices.Contains(ucs, "LPC")) && slices.Contains(h.remoteInfos[ski].UseCases, "LPC") {