18 lines
553 B
JavaScript
18 lines
553 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
|
|
|
|
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 = {
|
|
"payload": {
|
|
"action": scripts
|
|
}
|
|
}
|
|
|
|
node.send(sendScripts)
|
|
node.status({fill:'green',shape:'dot',text:'Scripts Sent'}) |