notififications / alerts/ emails on change in sensor value

Hi

is there a way to send notifications / emails upon change in sensor values? I have have read through some of the post from several years suggesting using pushover app. I wondering if there has been any other features / methods added since. Also Pushover is not free- if possible I am looking for a free application :slight_smile:

Thanks

Hi

I don't know if this is what you have in mind.
I found it at a quick Google search.

There's talk about successfully Telnetting directly into the mail server.....

https://community.spiceworks.com/topic/265337-how-to-send-email-from-command-line-in-windows-7

It is possible to send e-mails from within rules. The old forum had an example how to send e-mails using gmail mail server. Maybe you can spot it somewhere. If not, let me know and I’ll find a snippet of code.

Kind regards,

Michal

hi Michal

i would appreciate when you get a chance if you send me some example of what you have executed or if you find the link to the post in the old forum. Its hard find old post by search after they were all archived.

Thanks

This should work in controller 2.2 https://openremote.github.io/archive-dotorg/forums/Emails,%20Text-to-Speech,%20Serial%20Port.html
but I have no idea if it was ported to 2.5 or 2.6.

In any case, this little Java hacking will allow you to always send emails https://openremote.github.io/archive-dotorg/forums/22872974.html

Personally, I use the second method as it supports attachments.

HI MIchal,

i tried the instructions at this link you suggested below but i am getting errors- i am wondering if it has to do with the OR 2.6 beta with new drools version or Java version 8

https://openremote.github.io/archive-dotorg/forums/22872974.html

below is the copy of the rule and the error messages- i hope its something simple :slight_smile: Any help is greatly appreciated.

I have 2 drl files in the rules folder - one with working set of rules and other with the rule for email for testing.

//trial email with orcbeta2.6

package org.openremote.controller.model.event

global org.openremote.controller.statuscache.CommandFacade execute;

global org.openremote.controller.statuscache.SwitchFacade switches;

global org.openremote.controller.statuscache.LevelFacade levels;

import org.openremote.controller.protocol.Event;

import java.util.Properties;

import javax.mail.Message;

import javax.mail.MessagingException;

import javax.mail.PasswordAuthentication;

import javax.mail.Session;

import javax.mail.Transport;

import javax.mail.internet.InternetAddress;

import javax.mail.internet.MimeMessage;

// email notifications

rule “Send mail”

when

Switch ( source == “Send mail sensor”, value == “on”)

then

execute.command (“Send mail OFF”);

final String username = “orc@gmail.com”;

final String password = “mypassword”;

Properties props = new Properties();

props.put(“mail.smtp.host”, “smtp.gmail.com”);

props.put(“mail.smtp.socketFactory.port”, “465”);

props.put(“mail.smtp.socketFactory.class”,“javax.net.ssl.SSLSocketFactory”);

props.put(“mail.smtp.auth”, “true”);

props.put(“mail.smtp.port”, “465”);

Session session = Session.getInstance(props,

new javax.mail.Authenticator() {

protected PasswordAuthentication getPasswordAuthentication() {

return new PasswordAuthentication(username, password);

}

});

try {

Message message = new MimeMessage(session);

message.setFrom(new InternetAddress(“orc@gmail.com”));

message.setRecipients(Message.RecipientType.TO,

InternetAddress.parse(“orc@gmail.com”));

message.setSubject(“trial”);

message.setText(“triall triall”);

Transport.send(message);

System.out.println(“Mail sent”);

} catch (MessagingException e) {

throw new RuntimeException(e);

}

end

ERROR messages:

DEBUG 2017-03-12 22:16:12,460 : Starting event processor: Drools Rule Engine

DEBUG 2017-03-12 22:16:12,583 : Adding Rule ‘trial_modeler_rules.drl’…

DEBUG 2017-03-12 22:16:12,584 : Adding Rule ‘modeler_rules.drl’…

INFO 2017-03-12 22:16:21,149 : Starting device discovery service…

DEBUG 2017-03-12 22:16:21,150 : checking for discovered devices…

ERROR 2017-03-12 22:16:22,581 : Rule definition ‘trial_modeler_rules.drl’ could not be deployed. See errors below.

ERROR 2017-03-12 22:16:22,584 : Rule Compilation error Only a type can be imported. javax.mail.PasswordAuthentication resolves to a package

Only a type can be imported. javax.mail.internet.InternetAddress resolves to a package

Only a type can be imported. javax.mail.Message resolves to a package

Only a type can be imported. javax.mail.Transport resolves to a package

Only a type can be imported. javax.mail.MessagingException resolves to a package

Only a type can be imported. javax.mail.Session resolves to a package

Only a type can be imported. javax.mail.internet.MimeMessage resolves to a package

Session cannot be resolved to a type

Session cannot be resolved

javax.mail.Authenticator cannot be resolved to a type

Message cannot be resolved to a type

MimeMessage cannot be resolved to a type

InternetAddress cannot be resolved to a type

Message.RecipientType.TO cannot be resolved to a type

InternetAddress cannot be resolved

Transport cannot be resolved

MessagingException cannot be resolved to a type

ERROR 2017-03-12 22:16:22,586 : Error importing : ‘javax.mail.PasswordAuthentication’

ERROR 2017-03-12 22:16:22,586 : Error importing : ‘javax.mail.internet.MimeMessage’

ERROR 2017-03-12 22:16:22,587 : Error importing : ‘javax.mail.MessagingException’

ERROR 2017-03-12 22:16:22,588 : Error importing : ‘javax.mail.internet.InternetAddress’

ERROR 2017-03-12 22:16:22,588 : Error importing : ‘javax.mail.Session’

ERROR 2017-03-12 22:16:22,589 : Error importing : ‘javax.mail.Transport’

ERROR 2017-03-12 22:16:22,590 : Error importing : ‘javax.mail.Message’

INFO 2017-03-12 22:16:24,056 : Added rule definition ‘modeler_rules.drl’ to knowledge.

INFO 2017-03-12 22:16:33,971 : Started event processor : Drools Rule Engine

Indeed, I would first try to find a newer version of javax.mail.jar.

Sorry about my ignorance on Java but i found where i can get the javax.mail.jar file at this link
https://java.net/projects/javamail/pages/Home#Download_JavaMail_Release

but i am not sure where I should be saving that file at in my java folder - I am using OR2.6 on Raspberry pi

Save it in webapps/controller/WEB-INF/lib

Thanks Michal- that took care of all the import errors and the rule is not getting added successfully to the Drools engine. However, upon execution of the command, it is throwing these errors ( i have verified t he username passwords are correct):

ERROR 2017-03-18 09:42:10,539 : Error in executing rule : Send mail sensor:Exception executing consequence for rule “Send mail” in org.openremote.controller.model.event: java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

Event Switch Event (ID = 400986, Source = ‘Send mail sensor’, Switch Value = ‘on’, Switch State = ON) not processed!

Exception executing consequence for rule “Send mail” in org.openremote.controller.model.event: java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)

at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1100)

at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121)

at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)

at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1007)

at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1350)

at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1288)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1306)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1297)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1278)

at org.openremote.controller.statuscache.rules.RuleEngine.push(RuleEngine.java:203)

at org.openremote.controller.statuscache.EventProcessorChain.push(EventProcessorChain.java:196)

at org.openremote.controller.statuscache.StatusCache.update(StatusCache.java:293)

at org.openremote.controller.model.sensor.Sensor.update(Sensor.java:367)

at org.openremote.controller.model.sensor.Sensor$DeviceReader.run(Sensor.java:655)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at org.openremote.controller.model.event.Rule_Send_mail1794327546.defaultConsequence(Rule_Send_mail1794327546.java:38)

at org.openremote.controller.model.event.Rule_Send_mail1794327546DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)

at org.openremote.controller.model.event.Rule_Send_mail1794327546DefaultConsequenceInvoker.evaluate(Unknown Source)

at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1089)

… 14 more

Caused by: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:932)

at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:843)

at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:748)

at javax.mail.Service.connect(Service.java:388)

at javax.mail.Service.connect(Service.java:246)

at javax.mail.Service.connect(Service.java:195)

at javax.mail.Transport.send0(Transport.java:254)

at javax.mail.Transport.send(Transport.java:124)

at org.openremote.controller.model.event.Rule_Send_mail1794327546.defaultConsequence(Rule_Send_mail1794327546.java:33)

… 17 more

ERROR [Polling Sensor Thread ID = 400986, Name =‘Send mail sensor’]: Error in executing rule : Send mail sensor:Exception executing consequence for rule “Send mail” in org.openremote.controller.model.event: java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

Event Switch Event (ID = 400986, Source = ‘Send mail sensor’, Switch Value = ‘on’, Switch State = ON) not processed!

Exception executing consequence for rule “Send mail” in org.openremote.controller.model.event: java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)

at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1100)

at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121)

at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)

at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1007)

at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1350)

at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1288)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1306)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1297)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1278)

at org.openremote.controller.statuscache.rules.RuleEngine.push(RuleEngine.java:203)

at org.openremote.controller.statuscache.EventProcessorChain.push(EventProcessorChain.java:196)

at org.openremote.controller.statuscache.StatusCache.update(StatusCache.java:293)

at org.openremote.controller.model.sensor.Sensor.update(Sensor.java:367)

at org.openremote.controller.model.sensor.Sensor$DeviceReader.run(Sensor.java:655)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at org.openremote.controller.model.event.Rule_Send_mail1794327546.defaultConsequence(Rule_Send_mail1794327546.java:38)

at org.openremote.controller.model.event.Rule_Send_mail1794327546DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)

at org.openremote.controller.model.event.Rule_Send_mail1794327546DefaultConsequenceInvoker.evaluate(Unknown Source)

at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1089)

… 14 more

Caused by: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:932)

at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:843)

at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:748)

at javax.mail.Service.connect(Service.java:388)

at javax.mail.Service.connect(Service.java:246)

at javax.mail.Service.connect(Service.java:195)

at javax.mail.Transport.send0(Transport.java:254)

at javax.mail.Transport.send(Transport.java:124)

at org.openremote.controller.model.event.Rule_Send_mail1794327546.defaultConsequence(Rule_Send_mail1794327546.java:33)

… 17 more

ERROR 2017-03-18 09:42:10,549 : Root Cause:

java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at org.openremote.controller.model.event.Rule_Send_mail1794327546.defaultConsequence(Rule_Send_mail1794327546.java:38)

at org.openremote.controller.model.event.Rule_Send_mail1794327546DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)

at org.openremote.controller.model.event.Rule_Send_mail1794327546DefaultConsequenceInvoker.evaluate(Unknown Source)

at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1089)

at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121)

at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)

at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1007)

at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1350)

at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1288)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1306)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1297)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1278)

at org.openremote.controller.statuscache.rules.RuleEngine.push(RuleEngine.java:203)

at org.openremote.controller.statuscache.EventProcessorChain.push(EventProcessorChain.java:196)

at org.openremote.controller.statuscache.StatusCache.update(StatusCache.java:293)

at org.openremote.controller.model.sensor.Sensor.update(Sensor.java:367)

at org.openremote.controller.model.sensor.Sensor$DeviceReader.run(Sensor.java:655)

at java.lang.Thread.run(Thread.java:745)

Caused by: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:932)

at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:843)

at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:748)

at javax.mail.Service.connect(Service.java:388)

at javax.mail.Service.connect(Service.java:246)

at javax.mail.Service.connect(Service.java:195)

at javax.mail.Transport.send0(Transport.java:254)

at javax.mail.Transport.send(Transport.java:124)

at org.openremote.controller.model.event.Rule_Send_mail1794327546.defaultConsequence(Rule_Send_mail1794327546.java:33)

… 17 more

ERROR [Polling Sensor Thread ID = 400986, Name =‘Send mail sensor’]: Root Cause:

java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at org.openremote.controller.model.event.Rule_Send_mail1794327546.defaultConsequence(Rule_Send_mail1794327546.java:38)

at org.openremote.controller.model.event.Rule_Send_mail1794327546DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)

at org.openremote.controller.model.event.Rule_Send_mail1794327546DefaultConsequenceInvoker.evaluate(Unknown Source)

at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1089)

at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121)

at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)

at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1007)

at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1350)

at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1288)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1306)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1297)

at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1278)

at org.openremote.controller.statuscache.rules.RuleEngine.push(RuleEngine.java:203)

at org.openremote.controller.statuscache.EventProcessorChain.push(EventProcessorChain.java:196)

at org.openremote.controller.statuscache.StatusCache.update(StatusCache.java:293)

at org.openremote.controller.model.sensor.Sensor.update(Sensor.java:367)

at org.openremote.controller.model.sensor.Sensor$DeviceReader.run(Sensor.java:655)

at java.lang.Thread.run(Thread.java:745)

Caused by: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbut

534-5.7.14 -V0bbDuiQjk5qgZ7rNf0JgsDhF3pPPVFO8z3xDABB3_aw-ViyvVypT2dkevaNT3GftcoVD

534-5.7.14 ZDSCvvHbQsEnwt2ZO7IxdaqruBliGgo86LmTabX5PW3GrQpAqEbRPVRPZXWFuO8XVtZcpb

534-5.7.14 NXvvyuckZ2oYEW_0co3up3Fzt4FKnDTZAkYQCZ0uTCmPKH2oDHIhT-3VliE2K6qpQNNkFQ

534-5.7.14 UHfsYYWHAIz8ejxTdGleqDyIFZhfY> Please log in via your web browser and

534-5.7.14 then try again.

534-5.7.14 Learn more at

534 5.7.14 https://support.google.com/mail/answer/78754 z42sm8153108qtb.20 - gsmtp

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:932)

at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:843)

at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:748)

at javax.mail.Service.connect(Service.java:388)

at javax.mail.Service.connect(Service.java:246)

at javax.mail.Service.connect(Service.java:195)

at javax.mail.Transport.send0(Transport.java:254)

at javax.mail.Transport.send(Transport.java:124)

at org.openremote.controller.model.event.Rule_Send_mail1794327546.defaultConsequence(Rule_Send_mail1794327546.java:33)

The log says it all, it even points you to FAQ. Anyway, in short gmail disables API login by default. You must enable it manually before it will work. More details https://support.google.com/accounts/answer/6010255

thanks Michal- i did see that but i was a little concerned with the way it was portrayed on the account settings as “less secured apps access” and making account more vulnerable … anyways thanks again! after i switched that setting, it seems to be sending email with a press of a button. I will try to add more rules around triggers from sensors

greatly appreciate the quick responses!

Just create a separate gmail account for the “less secured apps access” and you are done.

agreed thanks!

Hi

The email API is work great. However with a lot so sensors connected to the controller, I have to create a seperate rule with the API which is making the rules file very long and hard to mange.

I want to see if there is a way to use $param concept or something else like that so there is only 1 rule for the email API and depending on which sensor triggers it, it will populate the message subject and body appropriately.

Any thoughts?

Yes, you can either use Event($source: source matches REGEX, …) or Event($s:source…)||Event($s:source,…) etc. Each time you will get triggering sensor name in the $s variable.

Have you seen the examples on the GitHub site?

https://github.com/openremote/Documentation/wiki/OpenRemote-Rules-examples

Specifically the fourth one, "Extract a text string from a custom sensor and pass to a command"

Michal and I have documented plenty of examples you could use as a starting place.

Good luck.