Starting to work on post-alert restoration

This commit is contained in:
2023-10-17 18:47:21 -04:00
parent d6a4b107a6
commit 591151f606
3 changed files with 77 additions and 15 deletions

View File

@ -5,6 +5,7 @@ const quiet = states["input_boolean.studio_quiet"].state
const stateTinaDesk = states["light.tina_desk_lights"].state
const stateLivingRoom = states["light.living_room_lights"].state
const stateDiningRoom = states["light.dining_room_lamp"].state
const stateStairwell = states["light.stairwell_led_strip"].state
const stateBasement = states["light.basement_studio_lights"].state
const adaptLivingRoom = states["switch.adaptive_lighting_living_room"].state
const adaptBasement = states["switch.adaptive_lighting_basement_studio"].state
@ -33,6 +34,7 @@ flow.set("nightBasement", nightBasement)
flow.set("stateTinaDesk", stateTinaDesk)
flow.set("stateLivingRoom", stateLivingRoom)
flow.set("stateDiningRoom", stateDiningRoom)
flow.set("stateStairwell", stateStairwell)
flow.set("stateBasement", stateBasement)
// Define empty arrays for backup scenes
@ -51,6 +53,7 @@ let colorName1 = effectType
let colorName2 = "white"
// Get lights to add to the backup scenes
//! We need to change this from one entire first floor scene to individual room scenes
if (stateTinaDesk === 'on') {
firstFloorLights.push('light.tina_desk_strip','light.tina_lamp_top','light.tina_lamp_side')
}
@ -63,6 +66,10 @@ if (stateDiningRoom === 'on') {
firstFloorLights.push('light.dining_room_lamp')
}
if (stateStairwell === 'on') {
firstFloorLights.push('light.stairwell_led_strip')
}
if (stateBasement === 'on') {
basementLights.push('light.basement_tall_lamp','light.basement_short_lamp','light.basement_stairwell','light.basement_led_strip_1')
}
@ -194,7 +201,8 @@ let sendLivingRoomStrip2 = {
"data": {
"zones": livingRoom2,
"color_name": colorName2,
"brightness": 255
"brightness": 255,
"power": true
}
}
}
@ -242,10 +250,62 @@ let sendDiningRoomLamp = {
}
}
let sendAdaptiveFirstFloor = {
"payload": {
"domain": "switch",
"service": "turn_off",
"target": {
"entity_id": adaptiveSwitchFirstFloor
},
"data": {}
}
}
let sendAdaptiveBasement = {
"payload": {
"domain": "switch",
"service": "turn_off",
"target": {
"entity_id": adaptiveSwitchBasement
},
"data": {}
}
}
let backupFirstFloor = {
"payload": {
"domain": "scene",
"service": "create",
"data": {
"scene_id": "first_floor_alert_restore",
"snapshot_entities": firstFloorLights
}
}
}
let backupBasement = {
"payload": {
"domain": "scene",
"service": "create",
"data": {
"scene_id": "basement_alert_restore",
"snapshot_entities": basementLights
}
}
}
let sendReset = {
"delay": delay
}
if (stateLivingRoom === 'on' && currentSceneLivingRoom != 'Alert') {
node.send([[backupFirstFloor],null,null,null,null,null])
}
if (stateBasement === 'on' && currentSceneBasement != 'Alert') {
node.send([[backupBasement],null,null,null,null,null])
}
// Send effect messages
if (effectBasement === true) {
node.send([null,null,null,null,[sendBasementStripFX,sendBasementLights,sendBasementStrip1,sendBasementStrip2],null])