diff --git a/climate/emma-bedroom/meltdown-center.js b/climate/emma-bedroom/meltdown-center.js index 79f549b..0279445 100644 --- a/climate/emma-bedroom/meltdown-center.js +++ b/climate/emma-bedroom/meltdown-center.js @@ -4,8 +4,10 @@ const ac = global.get('emmaBedroom.aircon.installed', "diskCon") const lastMode = flow.get("emmaBedroom.lastMode", "diskCon") const bedTemp = states['input_number.emma_bedroom_bedtime_temp'].state +const emmaBedroomAircon = ["climate.emma_bedroom_aircon"] + let setTemp = bedTemp -let setEco = 'none' +let setEco = 'turn_off' let setHvac = 'cool' let setAcFan = 'High' @@ -13,7 +15,7 @@ let sendHvac = { "payload": { "action": "climate.set_hvac_mode", "target": { - "entity_id": ["climate.emma_bedroom_aircon"] + "entity_id": emmaBedroomAircon }, "data": { "hvac_mode": setHvac @@ -25,7 +27,7 @@ let sendTemp = { "payload": { "action": "climate.set_temperature", "target": { - "entity_id": ["climate.emma_bedroom_aircon"] + "entity_id": emmaBedroomAircon }, "data": { "temperature": setTemp @@ -35,13 +37,11 @@ let sendTemp = { let sendEco = { "payload": { - "action": "climate.set_preset_mode", + "action": `switch.${setEco}`, "target": { - "entity_id": ["climate.emma_bedroom_aircon"] + "entity_id": ["switch.emma_bedroom_aircon_eco_mode"] }, - "data": { - "preset_mode": setEco - } + "data": {} } } @@ -49,7 +49,7 @@ let sendAcFan = { "payload": { "action": "climate.set_fan_mode", "target": { - "entity_id": ["climate.emma_bedroom_aircon"] + "entity_id": emmaBedroomAircon }, "data": { "fan_mode": setAcFan @@ -64,7 +64,7 @@ let reset = { if (toggle === 'on') { node.status({fill:"red",shape:"dot",text:"DANGER MODE ACTIVE"}) if (ac === 'on') { - node.send([[sendHvac,sendTemp,sendEco,sendTemp],null]) + node.send([[sendHvac,sendTemp,sendAcFan,sendEco],null]) } } else { node.status({fill:"green",shape:"dot",text:"Danger Mode Off"}) diff --git a/climate/emma-bedroom/processing.js b/climate/emma-bedroom/processing.js index 020105b..0ab6e0b 100644 --- a/climate/emma-bedroom/processing.js +++ b/climate/emma-bedroom/processing.js @@ -80,15 +80,15 @@ if (time === 'day') { if (ac === 'on') { if (danger === 'Extreme') { setTemp = nightTemp - setEco = "eco" + setEco = "turn_on" setHvac = "cool" } else if (hotDay === 'on' || heatWarning === 'on') { setTemp = dayTemp - setEco = "eco" + setEco = "turn_on" setHvac = "cool" } else { setTemp = nightTemp - setEco = "eco" + setEco = "turn_on" setHvac = "off" } } @@ -107,9 +107,9 @@ if (time === 'day') { setHvac = 'off' } if (hotDay === 'on') { - setEco = 'none' + setEco = 'turn_off' } else { - setEco = 'eco' + setEco = 'turn_on' } } } @@ -129,9 +129,9 @@ if (time === 'day') { } // Decide eco mode if (sleeping === 'on') { - setEco = 'none' + setEco = 'turn_off' } else { - setEco = 'eco' + setEco = 'turn_on' } // Decide HVAC mode if (schedMode === 'AC') { @@ -146,7 +146,7 @@ if (time === 'day') { setPeople = 'turn_off' if (ac === 'on') { setTemp = bedTemp - setEco = 'none' + setEco = 'turn_off' if (schedMode === 'AC') { setHvac = 'cool' } else if (schedMode === 'Fan') { @@ -247,13 +247,11 @@ let sendTemp = { let sendEco = { "payload": { - "action": "climate.set_preset_mode", + "action": `switch.${setEco}`, "target": { - "entity_id": emmaBedroomAircon + "entity_id": ["switch.emma_bedroom_aircon_eco_mode"] }, - "data": { - "preset_mode": setEco - } + "data": {} } } @@ -321,14 +319,14 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o } else { if (topic === 'emmabedroom-cooling' && ac === 'on') { node.status({ fill: "green", shape: "dot", text: "Cooling Schedule" }) - node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null]) + node.send([[sendHvac, sendTemp, sendAcFan, sendEco], null, null]) node.log("Emma Bedroom Climate: Auto/Cooling") } else if (topic === 'emmabedroom-bedtime') { node.send([null, sendPeople, null]) node.status({ fill: "green", shape: "dot", text: "Bedtime" }) node.log("Emma Bedroom Climate: Auto/Bedtime") if (validSchedModesAC.includes(schedMode) && ac === 'on') { - node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null]) + node.send([[sendHvac, sendTemp, sendAcFan, sendEco], null, null]) node.log("Emma Bedroom Climate: Auto/Bedtime/AC") } else if (schedMode === 'White Noise') { node.send([null, sendWhiteNoise, null]) @@ -342,7 +340,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o node.send([null, sendWhiteNoise, null]) node.log("Emma Bedroom Climate: Auto/Wakeup/Sleep Off") if (ac === 'on') { - node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null]) + node.send([[sendHvac, sendTemp, sendAcFan, sendEco], null, null]) node.log("Emma Bedroom Climate: Auto/Wakeup/AC On") } } else if (sleeping === 'on') { @@ -359,7 +357,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o node.status({ fill: "blue", shape: "dot", text: "Manual Night" }) node.log("Emma Bedroom Climate: Manual/Night") if (ac === 'on') { - node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null]) + node.send([[sendHvac, sendTemp, sendAcFan, sendEco], null, null]) node.log("Emma Bedroom Climate: Manual/Night/AC") } } else if (time === 'day') { @@ -367,14 +365,14 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o node.send([null, sendWhiteNoise, null]) node.log("Emma Bedroom Climate: Manual/Day") if (ac === 'on') { - node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null]) + node.send([[sendHvac, sendTemp, sendAcFan, sendEco], null, null]) node.log("Emma Bedroom Climate: Manual/Day/AC") } } else if (time === 'bedtime') { node.status({ fill: "blue", shape: "dot", text: "Manual Bedtime" }) node.log("Emma Bedroom Climate: Manual/Bedtime") if (validSchedModesAC.includes(schedMode) && ac === 'on') { - node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null]) + node.send([[sendHvac, sendTemp, sendAcFan, sendEco], null, null]) node.log("Emma Bedroom Climate: Manual/Bedtime/AC") } else if (schedMode === 'White Noise') { node.send([null, sendWhiteNoise, null]) @@ -393,7 +391,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o node.send([null, [sendPeople, sendWhiteNoise], null]) node.log("Emma Bedroom Climate: Sleep/Bedtime") if (ac === 'on') { - node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null]) + node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null]) node.log("Emma Bedroom Climate: Sleep/Bedtime/AC") } } else { @@ -401,7 +399,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o node.send([null, sendWhiteNoise, null]) node.log("Emma Bedroom Climate: Sleep/Day") if (ac === 'on') { - node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null]) + node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null]) node.log(`Emma Bedroom Climate: Sleep/${convertToTitleCase(time)}/AC`) } }