Add light-level filter to upstairs bathroom motion lights
This commit is contained in:
11
second-floor-lighting/upstairs-bathroom/turn-on.js
Normal file
11
second-floor-lighting/upstairs-bathroom/turn-on.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const states = global.get('homeassistant.homeAssistant.states')
|
||||||
|
const lights = states['light.upstairs_bathroom_lights'].state
|
||||||
|
const lux = states['sensor.upstairs_bathroom_illuminance'].state
|
||||||
|
const threshold = states['input_number.upstairs_bathroom_lux_threshold'].state
|
||||||
|
|
||||||
|
if (lux <= threshold || lights === 'on') {
|
||||||
|
node.status({fill:'green',shape:'dot',text:'LightsOn'})
|
||||||
|
node.send(msg)
|
||||||
|
} else {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user