-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include Dynalene System and MTAirCompressor devices to Facility Map #474
Conversation
dynaleneP05Events.dynMainGridAlarm ? dynaleneP05Events.dynMainGridAlarm.value : null, | ||
dynaleneP05Events.dynMainGridFailureFlag ? dynaleneP05Events.dynMainGridFailureFlag.value : null, | ||
dynaleneP05Events.dynSafetyResetFlag ? dynaleneP05Events.dynSafetyResetFlag.value : null, | ||
dynaleneP05Events.dynTAalarm ? dynaleneP05Events.dynTAalarm.value : null, | ||
dynaleneP05Events.dynTMAalarm ? dynaleneP05Events.dynTMAalarm.value : null, | ||
dynaleneP05Events.dynaleneTankLevel ? (!dynaleneP05Events.dynaleneTankLevel.value === 0 ? true : false) : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines could be written more shortly. E.g:
const alarms_5 = [
dynaleneP05Events?.dynMainGridAlarm?.value,
dynaleneP05Events?.dynMainGridFailureFlag?.value,
...
];
If you are not explicitly comparing the default null
value, then this would do the same: it will return undefined
if the value is not defined, or the value if it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For line 219:
dynaleneP05Events?.dynaleneTankLevel?.value === 0
Is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @MiaRoseElbo, thanks! I've left a few comments, please take a look to them 🙏️
dynMainGridAlarm: HVACData['event-HVAC-0-dynMainGridAlarm']?.[0]?.state?.value ?? [], | ||
dynMainGridAlarmCMD: HVACData['event-HVAC-0-dynMainGridAlarmCMD']?.[0]?.state?.value ?? [], | ||
dynMainGridFailureFlag: HVACData['event-HVAC-0-dynMainGridFailureFlag']?.[0]?.state?.value ?? [], | ||
dynSafetyResetFlag: HVACData['event-HVAC-0-dynSafetyResetFlag']?.[0]?.state?.value ?? [], | ||
dynTAalarm: HVACData['event-HVAC-0-dynTAalarm']?.[0]?.state?.value ?? [], | ||
dynTAalarmCMD: HVACData['event-HVAC-0-dynTAalarmCMD']?.[0]?.state?.value ?? [], | ||
dynTAalarmMonitor: HVACData['event-HVAC-0-dynTAalarmMonitor']?.[0]?.state?.value ?? [], | ||
dynTMAalarm: HVACData['event-HVAC-0-dynTMAalarm']?.[0]?.state?.value ?? [], | ||
dynTMAalarmCMD: HVACData['event-HVAC-0-dynTMAalarmCMD']?.[0]?.state?.value ?? [], | ||
dynTMAalarmMonitor: HVACData['event-HVAC-0-dynTMAalarmMonitor']?.[0]?.state?.value ?? [], | ||
dynTankLevelAlarmCMD: HVACData['event-HVAC-0-dynTankLevelAlarmCMD']?.[0]?.state?.value ?? [], | ||
dynaleneState: HVACData['event-HVAC-0-dynaleneState']?.[0]?.state ?? [], | ||
dynaleneTankLevel: HVACData['event-HVAC-0-dynaleneTankLevel']?.[0]?.state?.value ?? [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you are unpacking the data please verify you are using proper default values. For instance event-HVAC-0-dynMainGridAlarm.state
is a Boolean, so the default value should be false
.
getAirCompressorStarted = (obj) => { | ||
for (let key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
if (obj[key] === true) { | ||
return key; | ||
} | ||
} | ||
} | ||
|
||
return 'Unknown'; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think making obj.hasOwnProperty
will always be true
as you are looping using the already present keys in the object. This can be simplified:
let trueKey = 'Unknown';
trueKey = Object.keys(obj).find(k => obj[k]);
return trueKey;
Remote: status1.startByRemote ? status1.startByRemote.value : false, | ||
TimeControl: status1.startWithTimerControl ? status1.startWithTimerControl.value : false, | ||
PressureRequirement: status1.startWithPressureRequirement ? status1.startWithPressureRequirement.value : false, | ||
DePressurise: status1.startAfterDePressurise ? status1.startAfterDePressurise.value : false, | ||
PowerLoss: status1.startAfterPowerLoss ? status1.startAfterPowerLoss.value : false, | ||
DryerPreRun: status1.startAfterDryerPreRun ? status1.startAfterDryerPreRun.value : false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified. E.g:
Remote: status1?.startByRemote?.value ?? false,
Remote: status2.startByRemote ? status2.startByRemote.value : false, | ||
TimeControl: status2.startWithTimerControl ? status2.startWithTimerControl.value : false, | ||
PressureRequirement: status2.startWithPressureRequirement ? status2.startWithPressureRequirement.value : false, | ||
DePressurise: status2.startAfterDePressurise ? status2.startAfterDePressurise.value : false, | ||
PowerLoss: status2.startAfterPowerLoss ? status2.startAfterPowerLoss.value : false, | ||
DryerPreRun: status2.startAfterDryerPreRun ? status2.startAfterDryerPreRun.value : false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified. Please check comment above.
alarms={{ | ||
alarm1: { | ||
name: 'Service Required', | ||
state: status1.serviceRequired ? status1.serviceRequired.value : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these declarations can be simplified. E.g:
state: status1?.serviceRequired?.value,
Also, this would only work if you are not explicitly comparing the default null
value afterwards.
alarms={{ | ||
alarm1: { | ||
name: 'Main Grid Alarm', | ||
state: dynaleneP05Events.dynMainGridAlarm ? dynaleneP05Events.dynMainGridAlarm.value : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to other few comments, I recommend to simplify this.
3dcbf52
to
99d2cd7
Compare
99d2cd7
to
ad34263
Compare
Add the Dynalene System from HVAC and MTAirCompressor to the Facility Cartoon