Initial commit
This commit is contained in:
63
lightfx/lightning-processing.js
Normal file
63
lightfx/lightning-processing.js
Normal file
@ -0,0 +1,63 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const allowed = states["binary_sensor.audible_weather_alerts_allowed"].state
|
||||
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 who = states["binary_sensor.audible_weather_alerts_allowed"].attributes.location
|
||||
const duration = msg.duration
|
||||
const payload = msg.payload
|
||||
|
||||
let firstFloorLights = []
|
||||
let basementLights = []
|
||||
|
||||
if (deskState === 'on') {
|
||||
firstFloorLights.push('light.tina_desk_strip','light.tina_lamp_top','light.tina_lamp_side')
|
||||
}
|
||||
|
||||
if (livingRoomState === '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') {
|
||||
firstFloorLights.push('light.dining_room_lamp')
|
||||
}
|
||||
|
||||
if (basementState === '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)
|
||||
|
||||
let firstFloorMsg = {
|
||||
"payload": payload,
|
||||
"duration": duration,
|
||||
"backup": firstFloorLights,
|
||||
"who": who
|
||||
}
|
||||
|
||||
let basementMsg = {
|
||||
"payload": payload,
|
||||
"duration": duration,
|
||||
"backup": basementLights
|
||||
}
|
||||
|
||||
if (allowed === 'on') {
|
||||
if (occupied === 'on' && quiet === 'off') {
|
||||
flow.set("basementTrigger","true")
|
||||
node.status({fill:"green",shape:"dot",text:"Both"})
|
||||
return[firstFloorMsg,basementMsg]
|
||||
} else {
|
||||
flow.set("basementTrigger","false")
|
||||
node.status({fill:"green",shape:"dot",text:"Living Room"})
|
||||
return[firstFloorMsg,null]
|
||||
}
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Blocked"})
|
||||
return null
|
||||
}
|
Reference in New Issue
Block a user