With OH1, I had a rule that emailed me the time and date of when my garage door was opened. But in OH2, this throws a java error in the log and no email received.
When I remove the time and date info, the email goes through and is received. So I’m guessing something changed within the NTP binding with OH2 to show this info?
In my former OH1 rule, I had this previously:
sendMail("myemail@xxx.com", "Garage Door Opened", "The Garage Door was opened at " + Date.state.format("%tr") + " on "+ Date.state.format("%tD") + ".")
My Door sensor isn’t working but I can test it again tonight. But if I remember I had an issue with the NTP binding not being installed and the original code did work.
Did you try this?
sendMail("myemail@myaddress.com", "Garage Door Opened", "The Garage Door was opened at " + Date.state.format("%tr") + " on "+ Date.state.format("%tD") + ".")
I just tried your method as I like it better, but it didn’t work. I get this error message:
Error during the execution of rule FRDoorbellTesting: An error occured during the script execution: The name 'Date' cannot be resolved to an item or type.
I didn’t realize that Date was an item. I figured it was a core function or something… Added the item (just copied and pasted yours), and now I get this in the log:
Error during the execution of rule FRDoorbellTesting: r != java.lang.String
It was, and the Thing was added as well (did this just before adding the item). I wondered if something got hung up, so I restarted OH2, and it fixed it. Your date method now works. Yay!!..