30 lines
848 B
JavaScript
30 lines
848 B
JavaScript
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 basement = {
|
|
"payload": {
|
|
"action": "script.goodnight_in_basement"
|
|
}
|
|
}
|
|
|
|
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'})
|
|
} |