dtoToDevice function
Device
dtoToDevice( - DeviceDTO device
)
Implementation
Device dtoToDevice(DeviceDTO device) {
return Device(
id: device.id!,
serialNumber: device.serialNumber!,
displayName: device.displayName ?? device.serialNumber,
address: dtoToDeviceAddress(device.address),
dealerOrg: dtoToDealerOrg(device.dealerOrgs?.firstOrNull),
modelNumber: device.modelDisplayName,
isConnected: device.isConnected ?? false,
deviceIpAddress: device.deviceIpAddress,
deviceHost: switch (device.deviceHost) {
DeviceHostDTO.oncue => DeviceHost.oncue,
DeviceHostDTO.homeenergyplatform => DeviceHost.homeEnergyPlatform,
DeviceHostDTO.swaggerGeneratedUnknown || null => null,
},
hasAcceptedPrivacyPolicy: device.hasAcceptedPrivacyPolicy,
status: dtoToDeviceStatus(device.status)!,
lastConnectedDate: device.lastConnectedTimestamp,
lastStatusUpdatedDate: device.statusUpdateTimestamp,
latestParameterUpdateDate: device.latestParameterUpdateTimestamp,
maintenanceDate: device.nextMaintenanceTimestamp,
alertCount: device.alertCount ?? 0,
connectionType: switch (device.connectionType) {
ConnectionTypeDTO.cellular => ConnectionType.cellular,
ConnectionTypeDTO.ethernet => ConnectionType.ethernet,
ConnectionTypeDTO.kohlerwifi => ConnectionType.kohlerWifi,
ConnectionTypeDTO.otherwifi => ConnectionType.otherWifi,
ConnectionTypeDTO.kohlercellkit => ConnectionType.kohlerCellKit,
ConnectionTypeDTO.unknown => ConnectionType.unknown,
ConnectionTypeDTO.swaggerGeneratedUnknown || null => null,
},
serviceAgreementStatus: switch (device.serviceAgreementStatus) {
ServiceAgreementStatusDTO.active => ServiceAgreementStatus.active,
ServiceAgreementStatusDTO.expired => ServiceAgreementStatus.expired,
ServiceAgreementStatusDTO.missingdata =>
ServiceAgreementStatus.missingData,
ServiceAgreementStatusDTO.none => ServiceAgreementStatus.none,
ServiceAgreementStatusDTO.swaggerGeneratedUnknown || null => null,
},
);
}