33 lines
1.5 KiB
JavaScript
33 lines
1.5 KiB
JavaScript
const states = global.get('homeassistant.homeAssistant.states')
|
|
const frontPorchToggle = states['input_boolean.front_porch_light_on'].state
|
|
const deliveryMode = states['input_boolean.delivery_mode'].state
|
|
const holidayMode = states['input_boolean.holiday_mode'].state
|
|
const holidayHold = states['input_boolean.holiday_mode_hold'].state
|
|
const currentHoliday = states['input_select.holiday_animation'].state
|
|
const earlyNight = states['binary_sensor.early_night_mode'].state
|
|
const holiday = currentHoliday.toLowerCase()
|
|
|
|
if (frontPorchToggle === 'on' && deliveryMode === 'off') {
|
|
if (earlyNight === 'off') {
|
|
if (holidayMode === 'on' && holidayHold === 'on') {
|
|
node.status({fill:"blue",shape:"dot",text:"Daytime (Holiday Hold)"})
|
|
node.send([msg,null])
|
|
} else {
|
|
node.status({fill:"red",shape:"ring",text:"Daytime"})
|
|
node.send([null,msg])
|
|
}
|
|
} else if (earlyNight === 'on') {
|
|
if (holidayMode === 'on') {
|
|
msg.holiday = holiday
|
|
node.status({fill:"blue",shape:"dot",text:"Night (Holiday On)"})
|
|
node.send([msg,null])
|
|
} else {
|
|
node.status({fill:"green",shape:"dot",text:"Night (Holiday Off)"})
|
|
node.send([null,msg])
|
|
}
|
|
}
|
|
} else if (frontPorchToggle === 'off') {
|
|
node.status({fill:"red",shape:"ring",text:"Blocked (Automation Off"})
|
|
} else if (deliveryMode === 'on') {
|
|
node.status({fill:"red",shape:"ring",text:"Blocked (Delivery Mode)"})
|
|
} |