From d4bf2e3f23d5ac6da5fe5ca02003295ba6f779aa Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 30 Apr 2025 15:38:31 -0400 Subject: [PATCH] Facilitate on-the-fly temperature changes in climate watchdog --- climate/emma-bedroom/set-temp-vars.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 climate/emma-bedroom/set-temp-vars.js diff --git a/climate/emma-bedroom/set-temp-vars.js b/climate/emma-bedroom/set-temp-vars.js new file mode 100644 index 0000000..38f112b --- /dev/null +++ b/climate/emma-bedroom/set-temp-vars.js @@ -0,0 +1,21 @@ +const topic = msg.topic +const payload = msg.payload +const lastMode = flow.get('emmaBedroom.lastMode', 'diskCon') + +if (topic === 'daytemp') { + flow.set('emmaBedroom.dayTemp', payload, 'diskCon') +} else if (topic === 'nighttemp') { + flow.set("emmaBedroom.nightTemp", payload, "diskCon") +} else if (topic === 'bedtemp') { + flow.set("emmaBedroom.bedTemp", payload, "diskCon") +} + +if (lastMode === 'day') { + flow.set('emmaBedroom.airconTargetTemp', flow.get('emmaBedroom.dayTemp', 'diskCon'), 'diskCon') +} else if (lastMode === 'night') { + flow.set('emmaBedroom.airconTargetTemp', flow.get('emmaBedroom.nightTemp', 'diskCon'), 'diskCon') +} else if (lastMode === 'bedtime') { + flow.set('emmaBedroom.airconTargetTemp', flow.get('emmaBedroom.bedTemp', 'diskCon'), 'diskCon') +} + +node.status({fill:'green',shape:'dot',text:`Set ${topic} to ${payload}`}) \ No newline at end of file