Add comments, prepare for resets and multiple floors activation
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
// Set constants
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const occupied = states["binary_sensor.basement_occupied"].state
|
||||
const quiet = states["input_boolean.studio_quiet"].state
|
||||
@ -21,8 +22,7 @@ const delay = duration * 1000
|
||||
const adaptiveSwitchFirstFloor = flow.get("adaptiveFirstFloor", "diskCon")
|
||||
const adaptiveSwitchBasement = flow.get("adaptiveBasement", "diskCon")
|
||||
|
||||
//! Use delay in service calls, not duration
|
||||
|
||||
// Set flow contexts to be used later in the reset node
|
||||
flow.set("currentSceneBasement", currentSceneBasement)
|
||||
flow.set("currentSceneLivingRoom", currentSceneLivingRoom)
|
||||
flow.set("currentSceneTinaDesk", currentSceneTinaDesk)
|
||||
@ -35,17 +35,22 @@ flow.set("stateLivingRoom", stateLivingRoom)
|
||||
flow.set("stateDiningRoom", stateDiningRoom)
|
||||
flow.set("stateBasement", stateBasement)
|
||||
|
||||
// Define empty arrays for backup scenes
|
||||
let firstFloorLights = []
|
||||
let basementLights = []
|
||||
// Define empty arrays for basement LED strip zones
|
||||
let basement1 = []
|
||||
let basement2 = []
|
||||
let basementFull = []
|
||||
// Define empty arrays for living room LED strip zones
|
||||
let livingRoom1 = []
|
||||
let livingRoom2 = []
|
||||
let livingRoomFull = []
|
||||
// Color names are set by default, however certain effects can override them below
|
||||
let colorName1 = effectType
|
||||
let colorName2 = "white"
|
||||
|
||||
// Get lights to add to the backup scenes
|
||||
if (stateTinaDesk === 'on') {
|
||||
firstFloorLights.push('light.tina_desk_strip','light.tina_lamp_top','light.tina_lamp_side')
|
||||
}
|
||||
@ -62,6 +67,7 @@ if (stateBasement === 'on') {
|
||||
basementLights.push('light.basement_tall_lamp','light.basement_short_lamp','light.basement_stairwell','light.basement_led_strip_1')
|
||||
}
|
||||
|
||||
// Setup the proper zones to use for the effect
|
||||
if (effectDivide === 'half') {
|
||||
basement1 = flow.get("halfBasement1", "diskCon")
|
||||
basement2 = flow.get("halfBasement2", "diskCon")
|
||||
@ -77,7 +83,11 @@ if (effectDivide === 'half') {
|
||||
livingRoomFull = flow.get("livingRoomFull", "diskCon")
|
||||
}
|
||||
|
||||
//! Implement setting of colors here
|
||||
// Set/change colors if necessary
|
||||
if (effectType === 'police') {
|
||||
colorName1 = 'red'
|
||||
colorName2 = 'blue'
|
||||
}
|
||||
|
||||
// Set message payloads
|
||||
let sendBasementStripFX = {
|
||||
@ -232,6 +242,18 @@ let sendDiningRoomLamp = {
|
||||
}
|
||||
}
|
||||
|
||||
let sendReset = {
|
||||
"delay": delay
|
||||
}
|
||||
|
||||
// Send effect messages
|
||||
if (effectBasement === true) {
|
||||
node.send([null,null,null,null,[sendBasementStripFX,sendBasementLights,sendBasementStrip1,sendBasementStrip2],null])
|
||||
}
|
||||
}
|
||||
|
||||
if (effectFirstFloor === true) {
|
||||
node.send([null,[sendLivingRoomStripFX,sendLivingRoomLights,sendLivingRoomStrip1,sendLivingRoomStrip2],sendTinaDeskLights,sendDiningRoomLamp,null,null])
|
||||
}
|
||||
|
||||
// Send the reset message to start the timer
|
||||
node.send([null,null,null,null,null,sendReset])
|
20
lightfx/reset.js
Normal file
20
lightfx/reset.js
Normal file
@ -0,0 +1,20 @@
|
||||
// Set constants
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const currentSceneBasement = flow.get('currentSceneBasement')
|
||||
const currentSceneLivingRoom = flow.get('currentSceneLivingRoom')
|
||||
const currentSceneTinaDesk = flow.get('currentSceneTinaDesk')
|
||||
const adaptLivingRoom = flow.get('adaptLivingRoom')
|
||||
const adaptBasement = flow.get('adaptBasement')
|
||||
const nightLivingRoom = flow.get('nightLivingRoom')
|
||||
const nightBasement = flow.get('nightBasement')
|
||||
const stateTinaDesk = flow.get('stateTinaDesk')
|
||||
const stateLivingRoom = flow.get('stateLivingRoom')
|
||||
const stateDiningRoom = flow.get('stateDiningRoom')
|
||||
const stateBasement = flow.get('stateBasement')
|
||||
const scenesLivingRoom = flow.get('scenesLivingRoom', 'diskCon')
|
||||
const scenesBasement = flow.get('scenesBasement', 'diskCon')
|
||||
const scenesTinaDesk = flow.get('scenesTinaDesk', 'diskCon')
|
||||
|
||||
// Reset code goes here
|
||||
|
||||
node.status({fill:"green",shape:"dot",text:"Success"})
|
Reference in New Issue
Block a user