thanks for the answer. You are completely right. For me it’s hard to understand th new documentation about the mail binding. This is the reason why I am asking because I didn’t find anything related in this forum and also on Google.
23:09:58.346 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Test': The name 'sendMail' cannot be resolved to an item or type; line 12, column 2, length 58
This is the error message from the log when I am running the rule. This is my test rule:
rule "Test"
when
Item virt_Test received command
then
//val mailActions = getActions("mail", "mail:smtp:gmail")
logInfo("TEST ", "Regel wird geöffnet")
sendMail("thundermmgmx.de", "Test-Mail OpenHab ", "Huhu ")
end
I tried with the “val” command and mailActions.sendMail and without.
There was a typo in the address but also no success:
09:10:42.474 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule ‘Test’: ‘sendMail’ is not a member of ‘org.eclipse.smarthome.core.thing.binding.ThingActions’; line 10, column 2, length 71
Please post the Rule exactly is it is written for your latest test. What you have posted can never work. We have no idea what you’ve changed since posting that version.
This binding and action does work. I use it and get an email from it several times a day.
The error you quoted is because you failed to import that actions (commented out) and then tried to call sendMail without going through the imported actions.
In case you missed them, here are the examples from the docs:
val mailActions = getActions("mail","mail:smtp:sampleserver")
mailActions.sendMail("mail@example.com", "Test subject", "This is the mail content.")
import java.util.List
val List<String> attachmentUrlList = newArrayList(
"http://some.web/site/snap.jpg¶m=value",
"file:///tmp/201601011031.jpg")
val mailActions = getActions("mail","mail:smtp:sampleserver")
mailActions.sendHtmlMail("mail@example.com", "Test subject", "<h1>Header</h1>This is the mail content.", attachmentUrlList)
rule "send mail for testing"
when
Time cron "30 36 18 * * ?"
then
{
val mailActions = getActions("mail","mail:smtp:pairsmtp")
mailActions.sendMail("NewOpenhabAddy@testemailaddy.com", "Openhab Alert", "This is a test email")
}
end
Bundles in case it matters
openhab> bundle:list | grep ail
265 │ Active │ 80 │ 1.6.2 │ JavaMail API
266 │ Active │ 80 │ 1.5.0 │ Apache Commons Email
267 │ Active │ 80 │ 2.5.0.M2 │ openHAB Add-ons :: Bundles :: Mail Binding
error is:
2019-08-27 18:36:30.100 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘send mail for testing’: ‘sendMail’ is not a member of ‘org.eclipse.smarthome.core.thing.binding.ThingActions’; line 8, column 2, length 89
Is this not loading the “val” correctly? I was using similar info and just upgraded to 2.5.0 M2 today and most things work but I’m struggling to get this going.
You can also change this name when you first create the Thing.
I personally wish it were required to change it rather than only optionally letting you change it. I highly recommend that for all manually created Things that users replace the auto generated ID with something meaningful.
My paperui thing was matching mail:smtp:pairsmtp which I had created in a file. Not sure what helped, but I rebooted (again) and edited my thing file once more with a different name “mail:smtp:pairsmtp3” and edited my thing in paperui and now it’s working. I had tried this a few times 1,2, then the 3 worked for some reason. Should I typically skip doing a .things file and edit directly in paperui?
I now get an error:
[WARN ] [javax.mail ] - expected resource not found: /META-INF/javamail.default.address.map
but my email sends fine so I’m not too worried about it. Following another google search, I created a file in the only /META-INF folder I have but it didn’t help:
Technically it shouldn’t have allowed you to edit the Thing in PaperUI if it’s defined in a .things file. If it did let you without error, any changes you made will be lost on the next reload. You can only define a Thing in one way or the other.
I recommend using PaperUI or the REST API for Things definition.
I prefer consistency. Because I use automatically discovered Things, to be consistent, I define all my Things through PaperUI or the REST API regardless of the nature of the binding.
When you define your Things through PaperUI you are guaranteed to have a complete and syntactically correct Thing and it’s all self describing, no need to research the parameters and syntax required for each binding you use.
JSONDB is backed up automatically on every change and periodically. See $OH_USERDATA/jsondb/backups (e.g. /var/lib/openhab2/jsondb/backups).
Running openhab-cli backup/restore also backs up the contents of the JSONDB.
Any manual backup procedure you have must include parts of $OH_USERDATA anyway or else it is an incomplete backup. At a minimum it needs to include jsondb, and binding specific directory (e.g. zwave, mqtt), and persistence. If not it is only a partial backup.
Because the JSONDB is text based, you can even easily check it into git or your source control of choice and see diffs and stuff like that.
If you are manually backing up OH and not including folders like JSONDB from $OH_USERDATA, even if you don’t use PaperUI for anything, your backup is only a partial backup. If you are using openhab-cli to backup, then you are already backing up the jsondb. And if all you need to back up is the jsondb, well that’s handled for you.
I had the same issue, that my getActions() returned null.
I renamed the thing and adapted the rule, and then it worked.
So could be a workaround if someone is facing an issue.