Files
HA-NerdFlows-Functions/lightfx/processing-start.js

86 lines
3.3 KiB
JavaScript

const states = global.get('homeassistant.homeAssistant.states')
// Set some constants for all of the lights
// Half and half for living room LED strip
const halfLivingRoom1 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
const halfLivingRoom2 = [20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39]
// Quarters for living room LED strip
const segLivingRoom1 = [0,1,2,3,4,5,6,7,8,9]
const segLivingRoom2 = [10,11,12,13,14,15,16,17,18,19]
const segLivingRoom3 = [20,21,22,23,24,25,26,27,28,29]
const segLivingRoom4 = [30,31,32,33,34,35,36,37,38,39]
// Preset effect segments for living room LED strip
const effectSegLivingRoom1 = [].concat(segLivingRoom1, segLivingRoom3)
const effectSegLivingRoom2 = [].concat(segLivingRoom2, segLivingRoom4)
// Full strip for living room LED strip
const livingRoomFull = [].concat(halfLivingRoom1, halfLivingRoom2)
// Half and half for basement LED strip
const halfBasement1 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
const halfBasement2 = [16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
// Quarters for basement LED strip
const segBasement1 = [0,1,2,3,4,5,6,7]
const segBasement2 = [8,9,10,11,12,13,14,15]
const segBasement3 = [16,17,18,19,20,21,22,23]
const segBasement4 = [24,25,26,27,28,29,30,31]
// Preset effect segments for basement LED strip
const effectSegBasement1 = [].concat(segBasement1, segBasement3)
const effectSegBasement2 = [].concat(segBasement2, segBasement4)
// Full strip for basement LED strip
const basementFull = [].concat(halfBasement1, halfBasement2)
// Adaptive Lighting switches
const adaptiveFirstFloor = [
"switch.adaptive_lighting_living_room",
"switch.adaptive_lighting_dining_room_lamp",
"switch.adaptive_lighting_tina_lamp"]
const adaptiveBasement = [
"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
flow.set("halfLivingRoom1", halfLivingRoom1, "diskCon")
flow.set("halfLivingRoom2", halfLivingRoom2, "diskCon")
flow.set("segLivingRoom1", segLivingRoom1, "diskCon")
flow.set("segLivingRoom2", segLivingRoom2, "diskCon")
flow.set("segLivingRoom3", segLivingRoom3, "diskCon")
flow.set("segLivingRoom4", segLivingRoom4, "diskCon")
flow.set("effectSegLivingRoom1", effectSegLivingRoom1, "diskCon")
flow.set("effectSegLivingRoom2", effectSegLivingRoom2, "diskCon")
flow.set("livingRoomFull", livingRoomFull, "diskCon")
flow.set("halfBasement1", halfBasement1, "diskCon")
flow.set("halfBasement2", halfBasement2, "diskCon")
flow.set("segBasement1", segBasement1, "diskCon")
flow.set("segBasement2", segBasement2, "diskCon")
flow.set("segBasement3", segBasement3, "diskCon")
flow.set("segBasement4", segBasement4, "diskCon")
flow.set("effectSegBasement1", effectSegBasement1, "diskCon")
flow.set("effectSegBasement2", effectSegBasement2, "diskCon")
flow.set("basementFull", basementFull, "diskCon")
flow.set("adaptiveFirstFloor", adaptiveFirstFloor, "diskCon")
flow.set("adaptiveBasement", adaptiveBasement, "diskCon")
flow.set("scenesLivingRoom", scenesLivingRoom, "diskCon")
flow.set("scenesBasement", scenesBasement, "diskCon")
flow.set("scenesTinaDesk", scenesTinaDesk, "diskCon")