Goodnight should leave first floor alone if Kallen is waiting for school

home_automation/HA-NerdFlows#29
This commit is contained in:
2025-03-22 07:19:37 -04:00
parent 8dd7771eee
commit f8b528a9d2

18
housewide/goodnight.js Normal file
View File

@ -0,0 +1,18 @@
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'})