43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
const states = global.get('homeassistant.homeAssistant.states')
|
|
const earlyNightMode = states['binary_sensor.early_night_mode'].state
|
|
const giveMeDarkness = states['input_boolean.give_me_darkness'].state
|
|
const nightMode = states['input_boolean.night_mode'].state
|
|
const goodnight = states['input_boolean.goodnight'].state
|
|
const payload = msg.payload
|
|
|
|
let brt1 = 50
|
|
let brt2 = 100
|
|
let brt3 = 150
|
|
let brtmax = 255
|
|
let colortemp = {}
|
|
let brt = {}
|
|
|
|
if (earlyNightMode === 'off' && giveMeDarkness === 'off' && nightMode === 'off' && goodnight === 'off') {
|
|
colortemp = 4000
|
|
} else {
|
|
colortemp = 2000
|
|
}
|
|
|
|
if (goodnight === 'on') {
|
|
brt = brt1
|
|
} else if (nightMode === 'on') {
|
|
brt = brt3
|
|
} else if (giveMeDarkness === 'on') {
|
|
brt === brt2
|
|
} else if (earlyNightMode === 'on') {
|
|
brt = brt3
|
|
} else {
|
|
brt = brtmax
|
|
}
|
|
|
|
let msgAdjust = {
|
|
"brightness": brt,
|
|
"colortemp": colortemp
|
|
}
|
|
|
|
if (payload === 'on') {
|
|
node.status({fill:'green',shape:'dot',text:'Adjustments Sent'})
|
|
node.send(msgAdjust)
|
|
} else {
|
|
node.status({fill:'red',shape:'ring',text:'Light Off'})
|
|
} |