Complete fucking garbage, but I gotta save, outta time

This commit is contained in:
2023-10-20 18:22:46 -04:00
parent f758c36508
commit 8a002c6599
3 changed files with 97 additions and 66 deletions

View File

@ -35,7 +35,6 @@ let setServiceBasement = []
let restoreLivingRoom = {}
let restoreTinaDesk = {}
let restoreBasement = {}
let inputTexts = []
// Decide what to restore for each room
if (stateLivingRoom === 'on') {
@ -52,12 +51,11 @@ if (stateLivingRoom === 'on') {
} else {
restoreLivingRoom = 'backup'
setSceneLivingRoom = 'living_room_alert_restore'
inputTexts.push('input_text.living_room_selected_scene')
}
} else {
restoreLivingRoom = 'off'
setServiceLivingRoom = 'turn_off'
inputTexts.push('input_text.living_room_selected_scene')
setSceneLivingRoom = 'Adaptive'
}
if (stateTinaDesk === 'on') {
@ -72,7 +70,6 @@ if (stateTinaDesk === 'on') {
} else {
restoreTinaDesk = 'off'
setServiceTinaDesk = 'turn_off'
inputTexts.push('input_text.tina_desk_selected_scene')
}
if (stateDiningRoom === 'on') {
@ -84,7 +81,6 @@ if (stateDiningRoom === 'on') {
}
} else {
setServiceDiningRoom = 'turn_off'
inputTexts.push('input_text.dining_room_lamp_selected_scene')
}
if (stateBasement === 'on') {
@ -101,26 +97,14 @@ if (stateBasement === 'on') {
} else {
restoreBasement = 'backup'
setSceneBasement = 'basement_alert_restore'
inputTexts.push('input_text.basement_studio_selected_scene')
}
} else {
restoreBasement = 'off'
setServiceBasement = 'turn_off'
inputTexts.push('input_text.basement_studio_selected_scene')
setSceneBasement = 'Adaptive'
}
// Define messages
let sendInputTexts = {
"payload": {
"domain": "input_text",
"service": "set_value",
"target": {
"entity_id": inputTexts
},
"data": "Adaptive"
}
}
let sendSceneLivingRoom = {
"payload": {
"domain": "input_select",
@ -240,6 +224,17 @@ let sendStateDiningRoom = {
}
}
let sendStateBasement = {
"payload": {
"domain": "light",
"service": setServiceBasement,
"target": {
"entity_id": ["light.basement_studio_lights"]
},
"data": {}
}
}
let sendRestoreLivingRoom = {
"payload": {
"domain": "scene",
@ -262,6 +257,17 @@ let sendRestoreTinaDesk = {
}
}
let sendRestoreBasement = {
"payload": {
"domain": "scene",
"service": "turn_on",
"target": {
"entity_id": setSceneBasement
},
"data": {}
}
}
let sendStairwellScript = {
"payload": {
"domain": "script",
@ -283,33 +289,38 @@ let sendStairwellOff = {
// Send messages
if (restoreLivingRoom === 'backup') {
node.send([sendRestoreLivingRoom,null,null,null,null])
node.send([sendRestoreLivingRoom,null,null,null])
} else if (restoreLivingRoom === 'off') {
node.send([sendStateLivingRoom,null,null,null])
} else {
node.send([sendSceneLivingRoom,null,null,null,null])
node.send([sendSceneLivingRoom,null,null,null])
}
if (restoreTinaDesk === 'backup') {
node.send([null,sendRestoreTinaDesk,null,null,null])
node.send([null,sendRestoreTinaDesk,null,null])
} else if (restoreTinaDesk === 'off') {
node.send([null,sendStateTinaDesk,null,null])
} else {
node.send([null,sendSceneTinaDesk,null,null,null])
node.send([null,sendSceneTinaDesk,null,null])
}
if (stateDiningRoom === 'off') {
node.send([null,null,sendStateDiningRoom,null,null])
} else {
node.send([null,null,sendSceneDiningRoomLamp,null,null])
}
node.send([null,null,[sendStateDiningRoom,sendSceneDiningRoomLamp],null])
if (restoreBasement === 'backup') {
node.send([null,null,null,restoreBasement,null])
node.send([null,null,null,sendRestoreBasement])
} else if (restoreBasement === 'off') {
node.send([null,null,null,sendStateBasement])
} else {
node.send([null,null,null,sendSceneBasement,null])
node.send([null,null,null,sendSceneBasement])
}
if (stateStairwell === 'on') {
node.send([sendStairwellScript,null,null,null,null])
node.send([sendStairwellScript,null,null,null])
} else {
node.send([sendStairwellOff,null,null,null,null])
node.send([sendStairwellOff,null,null,null])
}
node.send([null,null,null,null,sendInputTexts])
flow.set('alertFirstFloor', false)
flow.set('alertBasement', false)
node.status({fill:'green',shape:'dot',text:'Scenes Reset'})