From 237041de10806190cc2806040027672022cbb85e Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 9 Oct 2023 16:11:35 -0400 Subject: [PATCH] Improve front porch light shutoff function --- front-porch/shut-off.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/front-porch/shut-off.js b/front-porch/shut-off.js index c1f17b0..a31ae85 100644 --- a/front-porch/shut-off.js +++ b/front-porch/shut-off.js @@ -1,18 +1,30 @@ 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 currentholiday = states['input_select.holiday_animation'].state -const holiday = currentholiday.toLowerCase() +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 (holidaymode === 'on') { - msg.holiday = holiday - node.status({fill:"blue",shape:"dot",text:"Holiday On"}) - node.send([msg,null]) - } else { - node.status({fill:"green",shape:"dot",text:"Holiday Off"}) - node.send([null,msg]) + 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"})