Hi there,
I have been writing rules which essentially perform diagnostics on the devices in each room, checking for IP connectivity, temperature states (fridges and freezers) for example.
I am really happy how this is progressing and now need to tackle a couple of issues that are not quite as easy for me to solve with my current knowledge base.
This one is bout items that have been removed from the system for example in winter I remove the fans from all the rooms and store them in the garage awaiting the next spring/summer time to come around.
Rather than the diagnostics always announce that the Fan is offline I would like to place the fan in a blacklist so that it would not be announced.
I thought about a whitelist approach but prefer a whitelist per room and a global blacklist.
I have created a blacklist that is called gDiags_Blklist but I am no quite sure how to check if _Online == OFF devices are a member of the blacklist group and if so do not include them in the offline announcements.
rule "Office Diagss"
when
Member of EchoCmds changed to "office diagnostics"
then
logInfo("diagnostics","Trigger: " + triggeringItem.name)
val sourceRoom = triggeringItem.name.split("_").get(0)
val _TTS = sourceRoom+"_Echo_TTS"
var String message = "All devices are working within specifications."
var String offlineDevices = "none"
// loop through all profiles (all members of group 'gHO_Diags')
logInfo("diagnostics", "Room: Office")
gHO_Diags.members.forEach[ profile |
var _Online = gHO_Diags.members.findFirst[ online | online.name == profile.name ]
var _item = profile.name.split("_").get(1)
logInfo("diagnostics"," item Name: "+_Online.name)
if (_Online.state ==ON ) {
logInfo("diagnostics"," item Online: "+_item)
} else {
logWarn("diagnostics"," item Offline: "+_item)
if (offlineDevices=="none") {
offlineDevices = _item.toString+", "
} else {
offlineDevices = offlineDevices + _item.toString+", "
}
}
]
if (offlineDevices!="none") { message = "The following devices were offline. "+offlineDevices }
createTimer(now.plusSeconds(1)) [ | {_TTS.sendCommand(message)}]
logInfo("diagnostics","Completed: "+message)
end
Thanks
Paul