Complete fucking garbage, but I gotta save, outta time
This commit is contained in:
@ -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'})
|
Reference in New Issue
Block a user