From b7914f8de6ae5ad2513dd941167b5b66246ce409 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 1 Oct 2023 07:47:34 +0200 Subject: [PATCH] fix: fix gcode command for generic_heater in presets (#1569) --- .../Temperature/TemperaturePanelPresets.vue | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/panels/Temperature/TemperaturePanelPresets.vue b/src/components/panels/Temperature/TemperaturePanelPresets.vue index f434e89cd..2230726f8 100644 --- a/src/components/panels/Temperature/TemperaturePanelPresets.vue +++ b/src/components/panels/Temperature/TemperaturePanelPresets.vue @@ -70,13 +70,23 @@ export default class TemperaturePanelPresets extends Mixins(BaseMixin) { preheat(preset: GuiPresetsStatePreset): void { for (const [name, attributes] of Object.entries(preset.values)) { if (attributes.bool) { - let gcode = `SET_HEATER_TEMPERATURE HEATER=${name} TARGET=${attributes.value}` + const splits = name.split(' ') + const printerObject = splits[0] + let printerObjectName = splits[1] ?? splits[0] - if (attributes.type === 'temperature_fan') { - const fanName = name.replace('temperature_fan ', '') - gcode = `SET_TEMPERATURE_FAN_TARGET temperature_fan=${fanName} TARGET=${attributes.value}` + // set default heater command + let command = 'SET_HEATER_TEMPERATURE' + let commandAttribute = 'HEATER' + + // override command for temperature_fan + if (printerObject === 'temperature_fan') { + command = 'SET_TEMPERATURE_FAN_TARGET' + commandAttribute = 'TEMPERATURE_FAN' } + // build gcode + const gcode = `${command} ${commandAttribute}=${printerObjectName} TARGET=${attributes.value}` + this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' }) this.$socket.emit('printer.gcode.script', { script: gcode }) }