public void HsEvent(Enums.HSEvent eventType, object[] parameters) { //Catch changes to values and store them for the devices we are watching _numberOfEventsReceived++; if (eventType == Enums.HSEvent.VALUE_CHANGE) { //_logging.LogDebug("Got an value changed event. Trying to check if we should store it"); _numberOfValueChanngeEventsReceived++; if (parameters != null && parameters.Length > 4 && parameters[2] != null && parameters[4] != null && parameters[2] is double && parameters[4] is int) { var newValue = (double)parameters[2]; var deviceId = (int)parameters[4]; //Console.WriteLine($"Something happened to a value for deviceId {deviceId} (value: {newValue.ToString()})"); if (DeviceIsWatched(deviceId)) { _logging.LogDebug($"logging an event with data deviceId:{deviceId} value: {newValue}"); _numberOfEventsStored++; _storageHandler.AddDeviceValueToDatabase(newValue, DateTime.Now, deviceId); } } } }