27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
const states = global.get('homeassistant.homeAssistant.states')
|
|
const outdoorLux = states['sensor.home_tempest_illuminance'].state
|
|
const threshold = states['input_number.front_porch_lux_threshold'].state
|
|
const frontPorchToggle = states['input_boolean.front_porch_light_on'].state
|
|
const holidaymode = states['input_boolean.holiday_mode'].state
|
|
const currentholiday = states['input_select.holiday_animation'].state
|
|
const holiday = currentholiday.toLowerCase()
|
|
|
|
let holidayMsg = {
|
|
"holiday": holiday
|
|
}
|
|
|
|
if ((outdoorLux >= threshold) && frontPorchToggle === 'on') {
|
|
if (holidaymode === 'on') {
|
|
node.status({fill:"blue",shape:"dot",text:"Holiday On"})
|
|
node.send([holidayMsg,msg])
|
|
} else {
|
|
node.status({fill:"green",shape:"dot",text:"Holiday Off"})
|
|
node.send([null,msg])
|
|
}
|
|
} else {
|
|
if (frontPorchToggle === 'off') {
|
|
node.status({ fill: "red", shape: "ring", text: "Disabled" })
|
|
} else if (outdoorLux < threshold) {
|
|
node.status({ fill: "red", shape: "ring", text: "Daytime" })
|
|
}
|
|
} |