Make sunset lighting depend on light level instead of weather
This commit is contained in:
@ -8,10 +8,11 @@ const holidayHold = states['input_boolean.holiday_mode_hold'].state
|
||||
const currentHoliday = states['input_select.holiday_animation'].state
|
||||
const holiday = currentHoliday.toLowerCase()
|
||||
const sunsetLights = states['input_boolean.sunset_lights_on'].state
|
||||
const weather = states['weather.iron_nerd_weather_station'].state
|
||||
const vacation = states['input_boolean.vacation_mode'].state
|
||||
const upBathOcc = states['binary_sensor.upstairs_bathroom_occupied'].state
|
||||
const deskLights = states['light.tina_desk_lights'].state
|
||||
const lux = states['sensor.living_room_illuminance'].state
|
||||
const luxThreshold = states['input_number.living_room_lux_threshold'].state
|
||||
const adaptiveSleep = flow.get("adaptiveSleep", "diskCon")
|
||||
const selScenesMain = flow.get("selScenesMain", "diskCon")
|
||||
const selScenesTinaDesk = flow.get("selScenesTinaDesk", "diskCon")
|
||||
@ -26,7 +27,7 @@ let topic = {}
|
||||
let delay = {}
|
||||
let eventCall = {}
|
||||
|
||||
if (payload == 0 || payload === 'weather') {
|
||||
if (payload == 0) {
|
||||
time = "night"
|
||||
eventCall = "on"
|
||||
} else if (payload == 1) {
|
||||
@ -34,15 +35,13 @@ if (payload == 0 || payload === 'weather') {
|
||||
eventCall = "off"
|
||||
}
|
||||
|
||||
if (msg.topic === 'timer-finished' || msg.topic === 'manual-trigger' || msg.topic === 'weather') {
|
||||
if (msg.topic === 'timer-finished' || msg.topic === 'manual-trigger' || msg.topic === 'lux') {
|
||||
topic = msg.topic
|
||||
}
|
||||
|
||||
if (topic === 'timer-finished' || topic === 'manual-trigger') {
|
||||
if (topic === 'timer-finished' || topic === 'manual-trigger' || topic === 'lux') {
|
||||
delay = 'off'
|
||||
} else if (topic === 'weather') {
|
||||
delay = 'off'
|
||||
} else if (weather === 'sunny' || weather === 'clear-night') {
|
||||
} else if (lux > luxThreshold) {
|
||||
delay = 'on'
|
||||
} else {
|
||||
delay = 'off'
|
||||
@ -95,17 +94,17 @@ if (sunsetLights === 'off') {
|
||||
sunsetStatus = "Skipped"
|
||||
} else {
|
||||
notifyTitle = "Sunset Lights On"
|
||||
if (topic === 'weather') {
|
||||
notifyMsg = "Lights on, delay cancelled due to weather change"
|
||||
sunsetStatus = "Weather Change"
|
||||
} else if (topic === 'timer-finished') {
|
||||
if (topic === 'timer-finished') {
|
||||
notifyMsg = "Lights on because timer was finished manually"
|
||||
sunsetStatus = "Manual Trigger"
|
||||
} else if (topic === 'lux') {
|
||||
notifyMsg = "Lights on because light level dropped below threshold"
|
||||
sunsetStatus = "Light Level Trigger"
|
||||
} else if (delay === 'on') {
|
||||
notifyMsg = "Lights on after delay due to clear weather"
|
||||
notifyMsg = "Lights on after delay due to sufficient light"
|
||||
sunsetStatus = "Delayed"
|
||||
} else if (delay === 'off') {
|
||||
notifyMsg = "Lights on early due to cloudy weather"
|
||||
notifyMsg = "Lights on early due to low light"
|
||||
sunsetStatus = "Early"
|
||||
}
|
||||
}
|
||||
@ -311,7 +310,8 @@ node.log("lightsOff: " + lightsOff)
|
||||
node.log("holidayMode: " + holidayMode)
|
||||
node.log("eventCall: " + eventCall)
|
||||
if (time === 'night') {
|
||||
node.log("weather: " + weather)
|
||||
node.log("lux: " + lux)
|
||||
node.log("luxThreshold: " + luxThreshold)
|
||||
node.log("delay: " + delay)
|
||||
node.log("sunsetStatus: " + sunsetStatus)
|
||||
}
|
||||
@ -344,7 +344,7 @@ if (vacation === 'off') {
|
||||
if (delay === 'on') {
|
||||
node.send([null,sendTimer,null,null])
|
||||
} else {
|
||||
if (topic === 'weather') {
|
||||
if (topic === 'lux') {
|
||||
node.send([null,sendTimerCancel,null,null])
|
||||
}
|
||||
node.send([null,null,[sendFirstFloorScene,sendSecondFloorScene],sendExtraLights])
|
||||
|
Reference in New Issue
Block a user