Skip to content
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

Merged
merged 3 commits into from
Jun 27, 2023

Conversation

MiaRoseElbo
Copy link
Contributor

Add the Dynalene System from HVAC and MTAirCompressor to the Facility Cartoon

@sebastian-aranda sebastian-aranda self-requested a review June 19, 2023 15:57
Comment on lines 214 to 219
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,
Copy link
Contributor

@sebastian-aranda sebastian-aranda Jun 19, 2023

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.

Copy link
Contributor

@sebastian-aranda sebastian-aranda Jun 19, 2023

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.

Copy link
Contributor

@sebastian-aranda sebastian-aranda left a 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 🙏️

Comment on lines 1714 to 1726
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 ?? [],
Copy link
Contributor

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.

Comment on lines 61 to 69
getAirCompressorStarted = (obj) => {
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
if (obj[key] === true) {
return key;
}
}
}

return 'Unknown';
};
Copy link
Contributor

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;

Comment on lines 103 to 108
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,
Copy link
Contributor

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,

Comment on lines 112 to 117
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,
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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.

@MiaRoseElbo MiaRoseElbo merged commit 0cf3538 into develop Jun 27, 2023
@MiaRoseElbo MiaRoseElbo deleted the tickets/LOVE-165 branch June 27, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants