@ -1,18 +1,30 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const schoolToday = states['input_boolean.kallen_school_today'].state
|
||||
const kallen = states['person.kallen_stork'].state
|
||||
const morning = states['binary_sensor.morning'].state
|
||||
|
||||
let scripts = ['script.goodnight_in_basement','script.goodnight_on_second_floor']
|
||||
|
||||
if ((schoolToday === 'on' && kallen != 'home') || schoolToday === 'off') {
|
||||
scripts.push('script.goodnight_on_first_floor')
|
||||
}
|
||||
|
||||
let sendScripts = {
|
||||
let basement = {
|
||||
"payload": {
|
||||
"action": scripts
|
||||
"action": "script.goodnight_in_basement"
|
||||
}
|
||||
}
|
||||
|
||||
node.send(sendScripts)
|
||||
node.status({fill:'green',shape:'dot',text:'Scripts Sent'})
|
||||
let firstFloor = {
|
||||
"payload": {
|
||||
"action": "script.goodnight_on_first_floor"
|
||||
}
|
||||
}
|
||||
|
||||
let secondFloor = {
|
||||
"payload": {
|
||||
"action": "script.goodnight_on_second_floor"
|
||||
}
|
||||
}
|
||||
|
||||
if (schoolToday === 'on' && kallen === 'home' && morning === 'on') {
|
||||
node.send([basement,secondFloor])
|
||||
node.status({fill:'yellow',shape:'dot',text:'Kallen waiting for school bus'})
|
||||
} else {
|
||||
node.send([basement,firstFloor,secondFloor])
|
||||
node.status({fill:'green',shape:'dot',text:'All scripts sent'})
|
||||
}
|
Reference in New Issue
Block a user