Fix issues with lux threshold conditions
This commit is contained in:
@ -1,20 +1,24 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const lights = states['light.stairwell_led_strip'].state
|
||||
const stairwellLights = states['light.stairwell_led_strip'].state
|
||||
const hallwayLights = states['light.hallway_overhead'].state
|
||||
const earlyNightMode = states['binary_sensor.early_night_mode'].state
|
||||
const nightMode = states['input_boolean.night_mode'].state
|
||||
const goodnight = states['input_boolean.goodnight'].state
|
||||
const duration = states['input_number.stairwell_lights_off_delay'].state
|
||||
const lux = states['sensor.stairwell_bottom_illuminance'].state
|
||||
const threshold = states['input_number.stairwell_lux_threshold'].state
|
||||
const lux = parseInt(states['sensor.stairwell_bottom_illuminance'].state)
|
||||
const threshold = parseInt(states['input_number.stairwell_lux_threshold'].state)
|
||||
const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold || lights === 'on') {
|
||||
if (lux <= threshold || stairwellLights === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
||||
node.send([msg,null])
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
}
|
||||
} else if (payload === 'off') {
|
||||
if (lights === 'on') {
|
||||
if (stairwellLights === 'on') {
|
||||
msg.duration = newDuration
|
||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||
node.send([null,msg])
|
||||
|
Reference in New Issue
Block a user