Fix Emma's door alert not checking if she's sleeping
Also added logging to try and nail down any future issues
This commit is contained in:
@ -16,6 +16,7 @@ let who = 'Master Bedroom'
|
||||
let tinaAvailable = false
|
||||
let tonyAvailable = false
|
||||
let enable = false
|
||||
let reason = {}
|
||||
|
||||
// Determine who is available to respond
|
||||
|
||||
@ -35,10 +36,14 @@ if (tinaAvailable === true || tonyAvailable === true) {
|
||||
|
||||
// Determine if the alert should be sent
|
||||
|
||||
if (overnight === 'on' && masterBedroomSleeping === 'on') {
|
||||
if (emmaSleep === 'on') {
|
||||
if (overnight === 'on' && masterBedroomSleeping === 'on') {
|
||||
enable = true
|
||||
} else if (overnight === 'off') {
|
||||
reason = 'Overnight is on, and master bedroom is sleeping'
|
||||
} else if (overnight === 'off') {
|
||||
enable = true
|
||||
reason = 'Overnight is off'
|
||||
}
|
||||
}
|
||||
|
||||
// Define the alert message
|
||||
@ -49,6 +54,26 @@ let alertTTS = {
|
||||
"type": "critical"
|
||||
}
|
||||
|
||||
// Add some logs for debugging
|
||||
|
||||
node.log(`--------------- Emma Door Alert --------------`)
|
||||
node.log(`Emma Door Alert - topic: ${topic}`)
|
||||
node.log(`Emma Door Alert - payload: ${payload}`)
|
||||
node.log(`Emma Door Alert - masterBedroomSleeping: ${masterBedroomSleeping}`)
|
||||
node.log(`Emma Door Alert - emmaSleep: ${emmaSleep}`)
|
||||
node.log(`Emma Door Alert - tonyAwake: ${tonyAwake}`)
|
||||
node.log(`Emma Door Alert - xiaDesktopUser: ${xiaDesktopUser}`)
|
||||
node.log(`Emma Door Alert - xiaDesktopIdle: ${xiaDesktopIdle}`)
|
||||
node.log(`Emma Door Alert - tonyLocation: ${tonyLocation}`)
|
||||
node.log(`Emma Door Alert - tinaLocation: ${tinaLocation}`)
|
||||
node.log(`Emma Door Alert - overnight: ${overnight}`)
|
||||
node.log(`Emma Door Alert - tonyAvailable: ${tonyAvailable}`)
|
||||
node.log(`Emma Door Alert - tinaAvailable: ${tinaAvailable}`)
|
||||
node.log(`Emma Door Alert - who: ${who}`)
|
||||
node.log(`Emma Door Alert - enable: ${enable}`)
|
||||
node.log(`Emma Door Alert - reason: ${reason}`)
|
||||
node.log(`----------------------------------------------`)
|
||||
|
||||
// Send the alert if conditions are met
|
||||
|
||||
if (topic === 'door' && payload === 'on') {
|
||||
|
Reference in New Issue
Block a user