This is a variation of the battery notification email alert, where I have OH send me a daily email of the state of the following groups:
GroupStatus = items in this group are switches and can be ON or OFF.
GroupTempReport = item in this group are the current temperatures of appliances.
I get this error:
failed: var String message = "\n"
When attempting to run this rule in OH3:
type: application/vnd.openhab.dsl.rule
var String message = "\n"
val report1 = GroupTempReport.allMembers.map[name + ": " + state.format("%s")].join("\n")
if (! GroupStatus.allMembers.filter([state == "OFF"]).empty) {
val report = GroupStatus.allMembers.filter([state == "OFF"]).map[
name + ": " + state.format("%s")
].join("\n")
message = message + " Openhab Items Offline:\n" + report+ "\n\n" + " Openhab Temperatures:\n" + report1
} else {
message = message + " All items Online" + " Openhab Temperatures:\n" + report1
}
logInfo("Status Update:", "Message: [{}]", message)
sendMail("me@gmail.com", "OpenHAB Status Message", message)
Oliver2
(Oliver)
November 21, 2021, 9:03pm
2
In file based rules it does not make any problems. Is your header/trigger section of your GUI based rule valid?
Anyway, you will not see anything in your log file as it only gives out the first line (which is empty)
var String message = "\n"
...
logInfo("Status Update:", "Message: [{}]", message)
opnhab7373
(Joshua A)
November 22, 2021, 12:22am
3
This was the issue. I was attempting to run the rule without a trigger. I am still feeling my way around OH3 GUI and the transition from OH2 leads me into some of these skipped steps. Thank you. I’ll post the whole setup in an Rules example post.
Thank you.
opnhab7373
(Joshua A)
November 22, 2021, 12:42am
4
An example of daily status report email here.
This is a solution to a need for a day status update on Things as well as some important temperatures.
Prerequisites:
Mail Binding with a SMTP thing created
Group for items that indicate thing status
Group for items that reflect important temperatures
Steps:
enable your Mail Binding and add a SMTP thing. Example below will have mail:smtp:YOURSMTPTHING
Create a Group named GroupStatus and add the Status Items that you wish to receive the report on.
Create a Group named GroupTempReport and …