Starting to work on post-alert restoration
This commit is contained in:
@ -1,4 +1,3 @@
|
|||||||
const states = global.get('homeassistant.homeAssistant.states')
|
|
||||||
// Set some constants for all of the lights
|
// Set some constants for all of the lights
|
||||||
|
|
||||||
// Half and half for living room LED strip
|
// Half and half for living room LED strip
|
||||||
@ -45,11 +44,6 @@ const adaptiveBasement = [
|
|||||||
"switch.adaptive_lighting_basement_studio"
|
"switch.adaptive_lighting_basement_studio"
|
||||||
]
|
]
|
||||||
|
|
||||||
// Room scene options
|
|
||||||
const scenesLivingRoom = states["input_select.living_room_scenes"].attributes.options
|
|
||||||
const scenesBasement = states["input_select.basement_studio_scenes"].attributes.options
|
|
||||||
const scenesTinaDesk = states["input_select.tina_desk_scenes"].attributes.options
|
|
||||||
|
|
||||||
// Write flow variables
|
// Write flow variables
|
||||||
flow.set("halfLivingRoom1", halfLivingRoom1, "diskCon")
|
flow.set("halfLivingRoom1", halfLivingRoom1, "diskCon")
|
||||||
flow.set("halfLivingRoom2", halfLivingRoom2, "diskCon")
|
flow.set("halfLivingRoom2", halfLivingRoom2, "diskCon")
|
||||||
@ -79,7 +73,3 @@ flow.set("basementFull", basementFull, "diskCon")
|
|||||||
|
|
||||||
flow.set("adaptiveFirstFloor", adaptiveFirstFloor, "diskCon")
|
flow.set("adaptiveFirstFloor", adaptiveFirstFloor, "diskCon")
|
||||||
flow.set("adaptiveBasement", adaptiveBasement, "diskCon")
|
flow.set("adaptiveBasement", adaptiveBasement, "diskCon")
|
||||||
|
|
||||||
flow.set("scenesLivingRoom", scenesLivingRoom, "diskCon")
|
|
||||||
flow.set("scenesBasement", scenesBasement, "diskCon")
|
|
||||||
flow.set("scenesTinaDesk", scenesTinaDesk, "diskCon")
|
|
||||||
|
@ -5,6 +5,7 @@ const quiet = states["input_boolean.studio_quiet"].state
|
|||||||
const stateTinaDesk = states["light.tina_desk_lights"].state
|
const stateTinaDesk = states["light.tina_desk_lights"].state
|
||||||
const stateLivingRoom = states["light.living_room_lights"].state
|
const stateLivingRoom = states["light.living_room_lights"].state
|
||||||
const stateDiningRoom = states["light.dining_room_lamp"].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 stateBasement = states["light.basement_studio_lights"].state
|
||||||
const adaptLivingRoom = states["switch.adaptive_lighting_living_room"].state
|
const adaptLivingRoom = states["switch.adaptive_lighting_living_room"].state
|
||||||
const adaptBasement = states["switch.adaptive_lighting_basement_studio"].state
|
const adaptBasement = states["switch.adaptive_lighting_basement_studio"].state
|
||||||
@ -33,6 +34,7 @@ flow.set("nightBasement", nightBasement)
|
|||||||
flow.set("stateTinaDesk", stateTinaDesk)
|
flow.set("stateTinaDesk", stateTinaDesk)
|
||||||
flow.set("stateLivingRoom", stateLivingRoom)
|
flow.set("stateLivingRoom", stateLivingRoom)
|
||||||
flow.set("stateDiningRoom", stateDiningRoom)
|
flow.set("stateDiningRoom", stateDiningRoom)
|
||||||
|
flow.set("stateStairwell", stateStairwell)
|
||||||
flow.set("stateBasement", stateBasement)
|
flow.set("stateBasement", stateBasement)
|
||||||
|
|
||||||
// Define empty arrays for backup scenes
|
// Define empty arrays for backup scenes
|
||||||
@ -51,6 +53,7 @@ let colorName1 = effectType
|
|||||||
let colorName2 = "white"
|
let colorName2 = "white"
|
||||||
|
|
||||||
// Get lights to add to the backup scenes
|
// 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') {
|
if (stateTinaDesk === 'on') {
|
||||||
firstFloorLights.push('light.tina_desk_strip','light.tina_lamp_top','light.tina_lamp_side')
|
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')
|
firstFloorLights.push('light.dining_room_lamp')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stateStairwell === 'on') {
|
||||||
|
firstFloorLights.push('light.stairwell_led_strip')
|
||||||
|
}
|
||||||
|
|
||||||
if (stateBasement === 'on') {
|
if (stateBasement === 'on') {
|
||||||
basementLights.push('light.basement_tall_lamp','light.basement_short_lamp','light.basement_stairwell','light.basement_led_strip_1')
|
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": {
|
"data": {
|
||||||
"zones": livingRoom2,
|
"zones": livingRoom2,
|
||||||
"color_name": colorName2,
|
"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 = {
|
let sendReset = {
|
||||||
"delay": delay
|
"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
|
// Send effect messages
|
||||||
if (effectBasement === true) {
|
if (effectBasement === true) {
|
||||||
node.send([null,null,null,null,[sendBasementStripFX,sendBasementLights,sendBasementStrip1,sendBasementStrip2],null])
|
node.send([null,null,null,null,[sendBasementStripFX,sendBasementLights,sendBasementStrip1,sendBasementStrip2],null])
|
||||||
|
@ -11,10 +11,22 @@ const stateTinaDesk = flow.get('stateTinaDesk')
|
|||||||
const stateLivingRoom = flow.get('stateLivingRoom')
|
const stateLivingRoom = flow.get('stateLivingRoom')
|
||||||
const stateDiningRoom = flow.get('stateDiningRoom')
|
const stateDiningRoom = flow.get('stateDiningRoom')
|
||||||
const stateBasement = flow.get('stateBasement')
|
const stateBasement = flow.get('stateBasement')
|
||||||
const scenesLivingRoom = flow.get('scenesLivingRoom', 'diskCon')
|
const scenesLivingRoom = states["input_select.living_room_scenes"].attributes.options
|
||||||
const scenesBasement = flow.get('scenesBasement', 'diskCon')
|
const scenesBasement = states["input_select.basement_studio_scenes"].attributes.options
|
||||||
const scenesTinaDesk = flow.get('scenesTinaDesk', 'diskCon')
|
const scenesTinaDesk = states["input_select.tina_desk_scenes"].attributes.options
|
||||||
|
|
||||||
// Reset code goes here
|
const definedLivingRoom = scenesLivingRoom.includes(currentSceneLivingRoom)
|
||||||
|
const definedBasement = scenesBasement.includes(currentSceneBasement)
|
||||||
|
const definedTinaDesk = scenesTinaDesk.includes(currentSceneTinaDesk)
|
||||||
|
|
||||||
|
let sendDebug = {
|
||||||
|
"scenesLivingRoom": scenesLivingRoom,
|
||||||
|
"scenesBasement": scenesBasement,
|
||||||
|
"scenesTinaDesk": scenesTinaDesk,
|
||||||
|
"definedLivingRoom": definedLivingRoom,
|
||||||
|
"definedBasement": definedBasement,
|
||||||
|
"definedTinaDesk": definedTinaDesk
|
||||||
|
}
|
||||||
|
|
||||||
|
node.send([sendDebug,null,null,null])
|
||||||
node.status({fill:"green",shape:"dot",text:"Success"})
|
node.status({fill:"green",shape:"dot",text:"Success"})
|
Reference in New Issue
Block a user