Files
HA-NerdFlows-Functions/climate/emma-bedroom/set-temp-vars.js

21 lines
860 B
JavaScript

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}`})