27 lines
1.3 KiB
JavaScript
27 lines
1.3 KiB
JavaScript
const states = global.get('homeassistant.homeAssistant.states')
|
|
const luxThresholdLivingRoom = states['input_number.living_room_lux_threshold'].state
|
|
const luxThresholdStairwell = states['input_number.stairwell_lux_threshold'].state
|
|
const luxThresholdOutdoor = states['input_number.sunset_lights_outdoor_lux_threshold'].state
|
|
const earlyNight = states['binary_sensor.early_night_mode'].state
|
|
const triggered = states['input_boolean.sunset_lights_triggered'].state
|
|
const level = msg.level
|
|
const room = msg.room
|
|
|
|
if (earlyNight === 'on' && triggered === 'off') {
|
|
if (room === 'living-room' && level <= luxThresholdLivingRoom) {
|
|
node.status({fill:'green',shape:'dot',text:'Sent (Living Room)'})
|
|
node.send([msg,msg])
|
|
} else if (room === 'stairwell-bottom' && level <= luxThresholdStairwell) {
|
|
node.status({fill:'green',shape:'dot',text:'Sent (Stairwell Bottom)'})
|
|
node.send([msg,msg])
|
|
} else if (room === 'outdoor' && level <= luxThresholdOutdoor) {
|
|
node.status({fill:'green',shape:'dot',text:'Sent (Outdoor)'})
|
|
node.send([msg,msg])
|
|
}
|
|
} else if (earlyNight === 'off') {
|
|
node.status({fill:'red',shape:'ring',text:'Not Evening'})
|
|
} else if (triggered === 'on') {
|
|
node.status({fill:'red',shape:'ring',text:'Already Triggered'})
|
|
} else {
|
|
node.status({fill:'red',shape:'ring',text:'No Action'})
|
|
} |