Functions code for Emma's bedroom climate flow
This commit is contained in:
72
climate/emma-bedroom/meltdown-center.js
Normal file
72
climate/emma-bedroom/meltdown-center.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const toggle = msg.payload
|
||||
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
|
||||
|
||||
let setTemp = bedTemp
|
||||
let setEco = 'none'
|
||||
let setHvac = 'cool'
|
||||
let setAcFan = 'High'
|
||||
|
||||
let sendHvac = {
|
||||
"payload": {
|
||||
"action": "climate.set_hvac_mode",
|
||||
"target": {
|
||||
"entity_id": ["climate.emma_bedroom_aircon"]
|
||||
},
|
||||
"data": {
|
||||
"hvac_mode": setHvac
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sendTemp = {
|
||||
"payload": {
|
||||
"action": "climate.set_temperature",
|
||||
"target": {
|
||||
"entity_id": ["climate.emma_bedroom_aircon"]
|
||||
},
|
||||
"data": {
|
||||
"temperature": setTemp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sendEco = {
|
||||
"payload": {
|
||||
"action": "climate.set_preset_mode",
|
||||
"target": {
|
||||
"entity_id": ["climate.emma_bedroom_aircon"]
|
||||
},
|
||||
"data": {
|
||||
"preset_mode": setEco
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sendAcFan = {
|
||||
"payload": {
|
||||
"action": "climate.set_fan_mode",
|
||||
"target": {
|
||||
"entity_id": ["climate.emma_bedroom_aircon"]
|
||||
},
|
||||
"data": {
|
||||
"fan_mode": setAcFan
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let reset = {
|
||||
"topic": "Reset"
|
||||
}
|
||||
|
||||
if (toggle === 'on') {
|
||||
node.status({fill:"red",shape:"dot",text:"DANGER MODE ACTIVE"})
|
||||
if (ac === 'on') {
|
||||
node.send([[sendHvac,sendTemp,sendEco,sendTemp],null])
|
||||
}
|
||||
} else {
|
||||
node.status({fill:"green",shape:"dot",text:"Danger Mode Off"})
|
||||
node.send([null,reset])
|
||||
}
|
||||
Reference in New Issue
Block a user