diff --git a/src/app/settings/settings.page.html b/src/app/settings/settings.page.html index cd21b706..39465cb3 100644 --- a/src/app/settings/settings.page.html +++ b/src/app/settings/settings.page.html @@ -51,10 +51,14 @@

{{"EXPORT" | translate}}

- + Temp: Export Brew By Weight - Xenia + + Temp: Export Brew By Weight - Sanremo + + {{"EXCEL_EXPORT" | translate}} diff --git a/src/app/settings/settings.page.ts b/src/app/settings/settings.page.ts index 93928d2f..63d1ef7a 100644 --- a/src/app/settings/settings.page.ts +++ b/src/app/settings/settings.page.ts @@ -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) { diff --git a/src/classes/devices/argosThermometer.ts b/src/classes/devices/argosThermometer.ts index 8957aadc..a812905e 100644 --- a/src/classes/devices/argosThermometer.ts +++ b/src/classes/devices/argosThermometer.ts @@ -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() { diff --git a/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.ts b/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.ts index 74e5bcfe..264e43c6 100644 --- a/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.ts +++ b/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.ts @@ -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(); @@ -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; @@ -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); + }); } }