Progress made on setting the necessary variables for lighting effects
This commit is contained in:
@ -1,36 +1,131 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const occupied = states["binary_sensor.basement_occupied"].state
|
||||
const quiet = states["input_boolean.studio_quiet"].state
|
||||
const deskState = states["light.tina_desk_lights"].state
|
||||
const livingRoomState = states["light.living_room_lights"].state
|
||||
const diningRoomState = states["light.dining_room_lamp"].state
|
||||
const basementState = states["light.basement_studio_lights"].state
|
||||
const where = msg.payload.event.where
|
||||
const type = msg.payload.event.type
|
||||
const stateTinaDesk = states["light.tina_desk_lights"].state
|
||||
const stateLivingRoom = states["light.living_room_lights"].state
|
||||
const stateDiningRoom = states["light.dining_room_lamp"].state
|
||||
const stateBasement = states["light.basement_studio_lights"].state
|
||||
const adaptLivingRoom = states["switch.adaptive_lighting_living_room"].state
|
||||
const adaptBasement = states["switch.adaptive_lighting_basement_studio"].state
|
||||
const nightLivingRoom = states["switch.adaptive_lighting_sleep_mode_living_room"].state
|
||||
const nightBasement = states["switch.adaptive_lighting_sleep_mode_basement_studio"].state
|
||||
const currentSceneBasement = states["input_text.basement_studio_selected_scene"].state
|
||||
const currentSceneLivingRoom = states["input_text.living_room_selected_scene"].state
|
||||
const currentSceneTinaDesk = states["input_text.tina_desk_selected_scene"].state
|
||||
const effectBasement = msg.payload.event.basement
|
||||
const effectFirstFloor = msg.payload.event.first_floor
|
||||
const effectType = msg.payload.event.type
|
||||
const effectDivide = msg.payload.event.divide
|
||||
const duration = msg.payload.event.duration
|
||||
const delay = duration * 1000
|
||||
const adaptiveSwitchFirstFloor = flow.get("adaptiveFirstFloor")
|
||||
const adaptiveSwitchBasement = flow.get("adaptiveBasement")
|
||||
|
||||
//! Use delay in service calls, not duration
|
||||
|
||||
flow.set("currentSceneBasement", currentSceneBasement)
|
||||
flow.set("currentSceneLivingRoom", currentSceneLivingRoom)
|
||||
flow.set("currentSceneTinaDesk", currentSceneTinaDesk)
|
||||
flow.set("adaptLivingRoom", adaptLivingRoom)
|
||||
flow.set("adaptBasement", adaptBasement)
|
||||
flow.set("nightLivingRoom", nightLivingRoom)
|
||||
flow.set("nightBasement", nightBasement)
|
||||
flow.set("stateTinaDesk", stateTinaDesk)
|
||||
flow.set("stateLivingRoom", stateLivingRoom)
|
||||
flow.set("stateDiningRoom", stateDiningRoom)
|
||||
flow.set("stateBasement", stateBasement)
|
||||
|
||||
let firstFloorLights = []
|
||||
let basementLights = []
|
||||
let basement1 = []
|
||||
let basement2 = []
|
||||
let basementFull = []
|
||||
let livingRoom1 = []
|
||||
let livingRoom2 = []
|
||||
let livingRoomFull = []
|
||||
|
||||
if (deskState === 'on') {
|
||||
if (stateTinaDesk === 'on') {
|
||||
firstFloorLights.push('light.tina_desk_strip','light.tina_lamp_top','light.tina_lamp_side')
|
||||
}
|
||||
|
||||
if (livingRoomState === 'on') {
|
||||
if (stateLivingRoom === 'on') {
|
||||
firstFloorLights.push('light.living_room_color_1','light.living_room_color_2','light.living_room_color_3','light.living_room_led_strip')
|
||||
}
|
||||
|
||||
if (diningRoomState === 'on') {
|
||||
if (stateDiningRoom === 'on') {
|
||||
firstFloorLights.push('light.dining_room_lamp')
|
||||
}
|
||||
|
||||
if (basementState === 'on') {
|
||||
if (stateBasement === 'on') {
|
||||
basementLights.push('light.basement_tall_lamp','light.basement_short_lamp','light.basement_stairwell','light.basement_led_strip_1')
|
||||
}
|
||||
|
||||
flow.set("deskState", deskState)
|
||||
flow.set("livingRoomState", livingRoomState)
|
||||
flow.set("diningRoomState", diningRoomState)
|
||||
flow.set("basementState", basementState)
|
||||
if (effectDivide === 'half') {
|
||||
basement1 = flow.get("halfBasement1")
|
||||
basement2 = flow.get("halfBasement2")
|
||||
livingRoom1 = flow.get("halfLivingRoom1")
|
||||
livingRoom2 = flow.get("halfLivingRoom2")
|
||||
} else if (effectDivide === 'quarter') {
|
||||
basement1 = flow.get("effectSegBasement1")
|
||||
basement2 = flow.get("effectSegBasement2")
|
||||
livingRoom1 = flow.get("effectSegLivingRoom1")
|
||||
livingRoom2 = flow.get("effectSegLivingRoom2")
|
||||
} else if (effectDivide === 'full') {
|
||||
basementFull = flow.get("basementFull")
|
||||
livingRoomFull = flow.get("livingRoomFull")
|
||||
}
|
||||
|
||||
// let segLivingRoom = [].concat(segLivingRoom1, segLivingRoom2)
|
||||
//! Implement setting of colors here
|
||||
|
||||
// Set message payloads
|
||||
let sendBasementStrip1 = {
|
||||
"payload": {
|
||||
"domain": "lifx",
|
||||
"service": "set_state",
|
||||
"target": {
|
||||
"entity_id": ["light.basement_led_strip_1"]
|
||||
},
|
||||
"data": {
|
||||
"zones": basement1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sendBasementStrip2 = {
|
||||
"payload": {
|
||||
"domain": "lifx",
|
||||
"service": "set_state",
|
||||
"target": {
|
||||
"entity_id": ["light.basement_led_strip_1"]
|
||||
},
|
||||
"data": {
|
||||
"zones": basement2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sendLivingRoomStrip1 = {
|
||||
"payload": {
|
||||
"domain": "lifx",
|
||||
"service": "set_state",
|
||||
"target": {
|
||||
"entity_id": ["light.living_room_led_strip"]
|
||||
},
|
||||
"data": {
|
||||
"zones": livingRoom1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sendLivingRoomStrip2 = {
|
||||
"payload": {
|
||||
"domain": "lifx",
|
||||
"service": "set_state",
|
||||
"target": {
|
||||
"entity_id": ["light.living_room_led_strip"]
|
||||
},
|
||||
"data": {
|
||||
"zones": livingRoom2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user