Skip to content

Commit

Permalink
Adding argos temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
graphefruit committed Sep 4, 2024
1 parent 5e05dad commit a6bfc9d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 35 deletions.
6 changes: 5 additions & 1 deletion src/app/settings/settings.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ <h2>{{"EXPORT" | translate}}</h2>
</ion-label>
<ion-icon name="chevron-forward-outline" slot="end"></ion-icon>
</ion-item>
<ion-item *ngIf='doWeHaveBrewByWeights()' (click)='exportBrewByWeight()' button tappable>
<ion-item *ngIf="doWeHaveBrewByWeights('xenia')" (click)="exportBrewByWeight('xenia')" button tappable>
<ion-label>Temp: Export Brew By Weight - Xenia</ion-label>
<ion-icon name="chevron-forward-outline" slot="end"></ion-icon>
</ion-item>
<ion-item *ngIf="doWeHaveBrewByWeights('sanremo')" (click)="exportBrewByWeight('sanremo')" button tappable>
<ion-label>Temp: Export Brew By Weight - Sanremo</ion-label>
<ion-icon name="chevron-forward-outline" slot="end"></ion-icon>
</ion-item>
<ion-item (click)="excelExport()" button tappable>
<ion-label>{{"EXCEL_EXPORT" | translate}}</ion-label>
<ion-icon name="chevron-forward-outline" slot="end"></ion-icon>
Expand Down
69 changes: 51 additions & 18 deletions src/app/settings/settings.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1219,46 +1219,79 @@ export class SettingsPage {
return `${newValue}`;
}

public doWeHaveBrewByWeights(): boolean {
public doWeHaveBrewByWeights(_type: string): boolean {
const allPreparations = this.uiPreparationStorage.getAllEntries();
for (const prep of allPreparations) {
if (
_type === 'xenia' &&
prep.connectedPreparationDevice.type === PreparationDeviceType.XENIA
) {
return true;
} else if (
_type === 'sanremo' &&
prep.connectedPreparationDevice.type ===
PreparationDeviceType.SANREMO_YOU
) {
return true;
}
}
}

public async exportBrewByWeight() {
public async exportBrewByWeight(_type: string) {
await this.uiAlert.showLoadingSpinner();
try {
const allXeniaPreps = [];
const allPreps = [];
let allPreparations = this.uiPreparationStorage.getAllEntries();
// Just take 60, else the excel will be exploding.
allPreparations = allPreparations.reverse().slice(0, 60);
for (const prep of allPreparations) {
if (
_type === 'xenia' &&
prep.connectedPreparationDevice.type === PreparationDeviceType.XENIA
) {
allXeniaPreps.push(prep);
allPreps.push(prep);
} else if (
_type === 'sanremo' &&
prep.connectedPreparationDevice.type ===
PreparationDeviceType.SANREMO_YOU
) {
allPreps.push(prep);
}
}

const allBrewsWithProfiles = this.uiBrewStorage
.getAllEntries()
.filter(
(e) =>
e.flow_profile !== null &&
e.flow_profile !== undefined &&
e.flow_profile !== '' &&
allXeniaPreps.find(
(pr) => pr.config.uuid === e.method_of_preparation
) &&
e.preparationDeviceBrew &&
e.preparationDeviceBrew.params &&
e.preparationDeviceBrew.params.brew_by_weight_active === true
);
let allBrewsWithProfiles = [];

if (_type === 'xenia') {
allBrewsWithProfiles = this.uiBrewStorage
.getAllEntries()
.filter(
(e) =>
e.flow_profile !== null &&
e.flow_profile !== undefined &&
e.flow_profile !== '' &&
allPreps.find(
(pr) => pr.config.uuid === e.method_of_preparation
) &&
e.preparationDeviceBrew &&
e.preparationDeviceBrew.params &&
e.preparationDeviceBrew.params.brew_by_weight_active === true
);
} else if (_type === 'sanremo') {
allBrewsWithProfiles = this.uiBrewStorage
.getAllEntries()
.filter(
(e) =>
e.flow_profile !== null &&
e.flow_profile !== undefined &&
e.flow_profile !== '' &&
allPreps.find(
(pr) => pr.config.uuid === e.method_of_preparation
) &&
e.preparationDeviceBrew &&
e.preparationDeviceBrew.params &&
e.preparationDeviceBrew.params.stopAtWeight > 0
);
}

const allBrewFlows: Array<{ BREW: Brew; FLOW: BrewFlow }> = [];
for await (const brew of allBrewsWithProfiles) {
Expand Down
18 changes: 11 additions & 7 deletions src/classes/devices/argosThermometer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,27 @@ export class ArgosThermometer extends TemperatureDevice {
ArgosThermometer.TEMPERATURE_CHAR_UUID,

async (_data: any) => {
let newData = new Uint8Array(_data.slice(0, -1));
this.parseStatusUpdate(newData);
const rawData = _data; //new Uint8Array(_data.slice(0, -1));
this.parseStatusUpdate(rawData);
},

(_data: any) => {}
);
}

private parseStatusUpdate(temperatureRawStatus: Uint8Array) {
private parseStatusUpdate(temperatureRawStatus: any) {
this.logger.log(
'temperatureRawStatus received is: ' + temperatureRawStatus
);
const formatNumber = new Intl.NumberFormat(undefined, {
minimumIntegerDigits: 2,
}).format;

const temperature_in_f =
temperatureRawStatus[-1] << (8 + temperatureRawStatus[-2]);
console.log('New temperature inc' + temperature_in_f);
this.setTemperature(temperature_in_f, temperatureRawStatus);
const setPoint =
((temperatureRawStatus.getUint16(5, true) / 127) * 5) / 9 - 32; // Convert from F to C
const data = formatNumber(setPoint);

this.setTemperature(Number(data), temperatureRawStatus);
}

private deattachNotification() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,7 @@ export class BrewBrewingGraphComponent implements OnInit {
.brewBrewingPreparationDeviceEl.preparationDevice as SanremoYOUDevice;

this.stopFetchingDataFromSanremoYOU();

const setSanremoData = () => {
const temp = prepDeviceCall.getTemperature();
const press = prepDeviceCall.getPressure();
Expand Down Expand Up @@ -2529,8 +2530,8 @@ export class BrewBrewingGraphComponent implements OnInit {
const isEspressoBrew: boolean =
this.data.getPreparation().style_type ===
PREPARATION_STYLE_TYPE.ESPRESSO;
this.textToSpeechWeightInterval = setInterval(() => {
this.ngZone.runOutsideAngular(() => {
this.ngZone.runOutsideAngular(() => {
this.textToSpeechWeightInterval = setInterval(() => {
if (this.flowProfileTempAll.length > 0) {
const actualScaleWeight =
this.flowProfileTempAll.slice(-1)[0].weight;
Expand All @@ -2550,18 +2551,15 @@ export class BrewBrewingGraphComponent implements OnInit {
}
}
}
});
}, this.settings.text_to_speech_interval_rate);

this.textToSpeechTimerInterval = setInterval(() => {
this.ngZone.runOutsideAngular(() => {
}, this.settings.text_to_speech_interval_rate);
this.textToSpeechTimerInterval = setInterval(() => {
this.textToSpeech.speak(
this.translate.instant('TEXT_TO_SPEECH.TIME') +
' ' +
this.data.brew_time
);
});
}, 5000);
}, 5000);
});
}
}

Expand Down

0 comments on commit a6bfc9d

Please sign in to comment.