Complete fucking garbage, but I gotta save, outta time
This commit is contained in:
@ -86,3 +86,6 @@ flow.set('lightsBasement', lightsBasement, 'diskCon')
|
||||
flow.set('lightsLivingRoom', lightsLivingRoom, 'diskCon')
|
||||
flow.set('lightsDiningRoom', lightsDiningRoom, 'diskCon')
|
||||
flow.set('lightsStairwell', lightsStairwell, 'diskCon')
|
||||
|
||||
flow.set('alertFirstFloor', false)
|
||||
flow.set('alertBasement', false)
|
@ -19,7 +19,7 @@ const currentSceneTinaDesk = states["input_text.tina_desk_selected_scene"].state
|
||||
const currentSceneDiningRoom = states["input_text.dining_room_lamp_selected_scene"].state
|
||||
const effectBasement = msg.payload.event.basement
|
||||
const effectFirstFloor = msg.payload.event.first_floor
|
||||
const effectType = msg.payload.event.type
|
||||
const effectColor = msg.payload.event.color
|
||||
const effectDivide = msg.payload.event.divide
|
||||
const duration = msg.payload.event.duration
|
||||
const delay = duration * 1000
|
||||
@ -29,6 +29,8 @@ const lightsTinaDesk = flow.get('lightsTinaDesk', 'diskCon')
|
||||
const lightsBasement = flow.get('lightsBasement', 'diskCon')
|
||||
const lightsLivingRoom = flow.get('lightsLivingRoom', 'diskCon')
|
||||
const lightsDiningRoom = flow.get('lightsDiningRoom', 'diskCon')
|
||||
const alertFirstFloor = flow.get('alertFirstFloor')
|
||||
const alertBasement = flow.get('alertBasement')
|
||||
|
||||
// Set flow contexts to be used later in the reset node
|
||||
flow.set("currentSceneBasement", currentSceneBasement)
|
||||
@ -55,10 +57,11 @@ let livingRoom1 = []
|
||||
let livingRoom2 = []
|
||||
let livingRoomFull = []
|
||||
// Color names are set by default, however certain effects can override them below
|
||||
let colorName1 = effectType
|
||||
let colorName1 = effectColor
|
||||
let colorName2 = "white"
|
||||
// Define empty array for input texts
|
||||
let inputTexts = []
|
||||
// Define empty object for LIFX effect settings
|
||||
let lifxData = {}
|
||||
let effectLifx = msg.payload.event.lifx
|
||||
|
||||
// Setup the proper zones to use for the effect
|
||||
if (effectDivide === 'half') {
|
||||
@ -77,43 +80,59 @@ if (effectDivide === 'half') {
|
||||
}
|
||||
|
||||
if (effectFirstFloor === true) {
|
||||
inputTexts.push('input_text.living_room_selected_scene','input_text.tina_desk_selected_scene')
|
||||
flow.set('alertFirstFloor', true)
|
||||
}
|
||||
|
||||
if (effectBasement === true) {
|
||||
inputTexts.push('input_text.basement_studio_selected_scene')
|
||||
flow.set('alertBasement', true)
|
||||
}
|
||||
|
||||
// Set/change colors if necessary
|
||||
if (effectType === 'police') {
|
||||
if (effectColor === 'police') {
|
||||
colorName1 = 'red'
|
||||
colorName2 = 'blue'
|
||||
}
|
||||
|
||||
// Set message payloads
|
||||
let sendInputTexts = {
|
||||
"payload": "input_text",
|
||||
"service": "set_value",
|
||||
"target": {
|
||||
"entity_id": inputTexts
|
||||
},
|
||||
"data": {
|
||||
"value": "Alert"
|
||||
// Define parameters for different LIFX effects
|
||||
if (effectLifx === 'move') {
|
||||
lifxData = {
|
||||
"speed": 0.5,
|
||||
"direction": "right",
|
||||
"power_on": false
|
||||
}
|
||||
} else if (effectLifx === 'ping') {
|
||||
effectLifx = 'pulse'
|
||||
colorName2 = colorName1
|
||||
lifxData = {
|
||||
"power_on": false,
|
||||
"mode": "ping",
|
||||
"period": 1,
|
||||
"cycles": duration,
|
||||
"color_name": "white",
|
||||
"brightness": 255
|
||||
}
|
||||
} else if (effectLifx === 'blink') {
|
||||
effectLifx = 'pulse'
|
||||
colorName2 = colorName1
|
||||
lifxData = {
|
||||
"power_on": false,
|
||||
"mode": "blink",
|
||||
"period": 0.5,
|
||||
"cycles": duration * 2,
|
||||
"color_name": "white",
|
||||
"brightness": 255
|
||||
}
|
||||
}
|
||||
|
||||
// Define messages
|
||||
let sendBasementStripFX = {
|
||||
"payload": {
|
||||
"domain": "lifx",
|
||||
"service": "effect_move",
|
||||
"service": "effect_" + effectLifx,
|
||||
"target": {
|
||||
"entity_id": ["light.basement_led_strip_1"]
|
||||
},
|
||||
"data": {
|
||||
"speed": 0.5,
|
||||
"direction": "right",
|
||||
"power_on": false
|
||||
}
|
||||
"data": lifxData
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,15 +188,11 @@ let sendBasementLights = {
|
||||
let sendLivingRoomStripFX = {
|
||||
"payload": {
|
||||
"domain": "lifx",
|
||||
"service": "effect_move",
|
||||
"service": "effect_" + effectLifx,
|
||||
"target": {
|
||||
"entity_id": ["light.living_room_led_strip"]
|
||||
},
|
||||
"data": {
|
||||
"speed": 0.5,
|
||||
"direction": "right",
|
||||
"power_on": false
|
||||
}
|
||||
"data": lifxData
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,26 +331,28 @@ let sendReset = {
|
||||
}
|
||||
|
||||
// Send backup messages
|
||||
if (stateLivingRoom === 'on' && currentSceneLivingRoom != 'Alert') {
|
||||
if (stateLivingRoom === 'on' && alertFirstFloor === false) {
|
||||
node.send([backupLivingRoom,null,null,null,null,null])
|
||||
}
|
||||
|
||||
if (stateTinaDesk === 'on' && currentSceneTinaDesk != 'Alert') {
|
||||
if (stateTinaDesk === 'on' && alertFirstFloor === false) {
|
||||
node.send([backupTinaDesk,null,null,null,null,null])
|
||||
}
|
||||
|
||||
if (stateBasement === 'on' && currentSceneBasement != 'Alert') {
|
||||
if (stateBasement === 'on' && alertBasement === false) {
|
||||
node.send([backupBasement,null,null,null,null,null])
|
||||
}
|
||||
|
||||
// Send effect messages
|
||||
if (effectBasement === true) {
|
||||
node.send([sendAdaptiveBasement,null,null,null,[sendBasementStripFX,sendBasementLights,sendBasementStrip1,sendBasementStrip2],null])
|
||||
node.send([null,null,null,null,[sendAdaptiveBasement,sendBasementLights,sendBasementStripFX,sendBasementStrip1,sendBasementStrip2],null])
|
||||
}
|
||||
|
||||
if (effectFirstFloor === true) {
|
||||
node.send([sendAdaptiveFirstFloor,[sendLivingRoomStripFX,sendLivingRoomLights,sendLivingRoomStrip1,sendLivingRoomStrip2],sendTinaDeskLights,sendDiningRoomLamp,null,null])
|
||||
node.send([null,[sendAdaptiveFirstFloor,sendLivingRoomLights,sendLivingRoomStripFX,sendLivingRoomStrip1,sendLivingRoomStrip2],sendTinaDeskLights,sendDiningRoomLamp,null,null])
|
||||
}
|
||||
|
||||
// Send the reset message to start the timer
|
||||
node.send([null,null,null,null,null,sendReset])
|
||||
node.send([null,null,null,null,null,sendReset])
|
||||
|
||||
node.status({fill:'green',shape:'dot',text:'Alert Sent'})
|
@ -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'})
|
Reference in New Issue
Block a user