Let's try this instead

home_automation/HA-NerdFlows#29
This commit is contained in:
2025-03-22 15:24:24 -04:00
parent f8b528a9d2
commit 6a6b5c2ae2

View File

@ -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'})
}