Startup.rule

openhab 2.5.9

Redoing my setup from a 3 year old version.
For the startup file, i used to be able to send an email upon startup; now i see this in the log file:

2020-10-20 19:00:01.703 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule ‘System starup initialization’: ‘sendMail’ is not a member of ‘org.eclipse.smarthome.core.thing.binding.ThingActions’; line 14, column 2, length 96

Startup.rules:

val mailActions = getActions(“mail”,“mail:smtp:”)

rule “System startup initialization”
when System started
then
mailActions.sendMail(“bla@gmail.com”, “System Startup Detected”, “System Startup Detected”)
end

I assume this never worked in 2.5.9? this is in the 2.5 Release Notes.

From https://github.com/openhab/openhab-distro/releases/tag/2.5.0

I think we already covered v1 - v2 mail Action.

This is probably one of those startup files timing races; you can get the Action before the binding is ready, or rather fail to get the action.
Moving the get to inside the rule delays the attempt a bit.

Sorry Rossko57, not sure how that pasted wrong:

This is what i put in there.
mailActions.sendMail(bla6@gmail.com", “System Startup Detected”, “System Startup Detected”)
I think you might be right; race condition…which is unfortunate; because it worked like a charm on the old version.

To clarify, I’m suggesting

rule "System startup initialization"
   when System started
then
   val mailActions = getActions("mail","mail:smtp:")
   mailActions.sendMail(“ ...

to shift the getAction from file load time to rule run time.

On the other hand, "mail:smtp:" looks deeply suspect

I’ll try that; the SMTP part is just obcuscated out; wasn’t sure if that ID is somehow unique to me and i shouldn’t be posting it :slight_smile:

Your Thing UIDs are unique to you, and of no use to anybody without access to your OH system.

Gotcha thanks! Also moving that inside the rule on startup works as well…appreciate the feedback! One day I’ll get this all updated…I have too many rules and things LOL.

Like SO many of the sendMail posts, I can not get this to work. I’ve read at least a dozen “solutions”, yet I still can not send email.

Here is the error…

2021-02-26 20:09:21.496 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Send Email': 'sendMail' is not a member of 'org.eclipse.smarthome.core.thing.binding.ThingActions'; line 53, column 19, length 89

Here is my “thing” config…

Thing mail:smtp:gmail [ hostname="smtp.gmail.com", sender="myuser@gmail.com", security="SSL", username="myuser", password="mypwd" ]

Here is my rule…

rule "Send Email"

when
    Item SendTestEmail changed to ON

then
    val mailActions = getActions("mail","mail:smtp:gmail")
    val success = mailActions.sendMail("3015551212@vtext.com", "Test subject", "This is the mail content.")

    SendTestEmail.postUpdate(OFF)

end

I have restarted my OH system. No change. Nothing ever defined via PaperUI. Just the ‘thing’ config and the rule.

Thanks.

Not being funny, but you have installed Mailbinding v2, not v1? and you definitely should not have the separate Mail Action v1.

1 Like

rossko57 –

Don’t worry about “funny”. I continue to struggle with each new binding, it seems. I am only using config files unless the PaperUI is mandatory.

OK, so the Mailbinding WAS an issue…now corrected. However, I am not clear regarding the Mail Action V1. Would you be kind enough to elaborate and hopefully provide the rule coding? I learn best by example. Clearly I misunderstood the docs that I read.

Thanks.

The Mail Action is an optional add-on, like bindings are. You don’t want it because you are instead using the Action integrated with the v2 Mail binding. If both are present, there can be conflicts. I don’t have any free code to explain that situation.

YIKES…I corrected / added the V2 mailbinding and then my system went into a high speed error loop (seen in logs) that I could ONLY stop via system shutdown.

Could this be the conflict between the V2 mailbinding and the rule with mailaction???

I am clueless how to get my system back online. I can send some of the logs if that will help.

This error seems to be the trigger point…

2021-02-27 10:56:35.312 [ERROR] [xbase.resource.BatchLinkableResource] - resolution of uriFragment '|::0.2.0.2.0.4.6.1.1.0.0.7.0.1.0.17.1.0.0.6::0::/1' failed.

java.lang.NullPointerException: null

There is no conflict between your rule and the v2 mail binding. That’s how you are supposed to use it, it’s right there in the docs.

Don’t have mail binding v1 as well.
Don’t have mail action as well.
If you do not use PaperUI then you should review your addons.cfg for these points.

If I am to assume that installation of the V2 Mailbinding is what sent my system into the error loop (it is the ONLY change I made)… is there a way to remove that binding (installed vial PaperUI) from the command line?? I am afraid that during the error loop, I am not be able to use the PaperUI to remove the binding before the logs overrun the SD card. Or I may not be able to get enough processor cycles to remove the binding.

I fear that I may lose my entire system at this point.

Many thousands of people have installed mail binding without disaster. Have you looked in your addons.cfg? Have you restarted even once so far?

Don’t even know what “addons.cfg” is or where it is located. I restart weekly, and did so twice today. Going to restart now and hope to get control of the system.

Okay, addons.cfg is the file used to control installation of add-on, like bindings, when you do not use PaperUI.

Found it. Looks ok. I have never edited this file, but it has the info entered via PaperUI.

System came back up without the previous error BUT my MQTT broker is now throwing errors, or OpenHAB attempting to connect to it is failing. I did not touch anything. Deleted and recreated all MQTT objects via PaperUI, keeping the same object ID number. Error persists. System not usable.

2021-02-27 13:29:34.288 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.1.229' with clientid 9b3fceb9-3c2c-4283-8a2b-319c5a1dc446
2021-02-27 13:29:34.312 [ERROR] [org.openhab.binding.mqtt            ] - bundle org.openhab.binding.mqtt:2.5.12 (258)[org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService(227)] : The activate method has thrown an exception
java.lang.IllegalArgumentException: ID segment 'MQTT Broker' contains invalid characters. Each segment of the ID must match the pattern [A-Za-z0-9_-]*.
	at org.eclipse.smarthome.core.common.AbstractUID.validateSegment(AbstractUID.java:97) ~[?:?]
	at org.eclipse.smarthome.core.common.AbstractUID.<init>(AbstractUID.java:75) ~[?:?]
	at org.eclipse.smarthome.core.common.AbstractUID.<init>(AbstractUID.java:58) ~[?:?]
	at org.eclipse.smarthome.core.thing.UID.<init>(UID.java:57) ~[?:?]
	at org.eclipse.smarthome.core.thing.ThingUID.<init>(ThingUID.java:43) ~[?:?]
	at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.brokerAdded(MqttServiceDiscoveryService.java:105) ~[?:?]
	at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.lambda$1(MqttServiceDiscoveryService.java:85) ~[?:?]
	at java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1597) ~[?:1.8.0_252]
	at java.util.Collections$UnmodifiableMap.forEach(Collections.java:1507) ~[?:1.8.0_252]
	at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.startBackgroundDiscovery(MqttServiceDiscoveryService.java:85) ~[?:?]
	at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.activate(AbstractDiscoveryService.java:384) ~[?:?]
	at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.activate(MqttServiceDiscoveryService.java:54) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:228) ~[bundleFile:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) ~[bundleFile:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664) ~[bundleFile:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510) [bundleFile:?]
	at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:317) [bundleFile:?]
	at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:307) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:340) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:982) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:955) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:900) [bundleFile:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) [org.eclipse.osgi-3.12.100.jar:?]
	at java.security.AccessController.doPrivileged(Native Method) [?:1.8.0_252]
	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:508) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:624) [org.eclipse.osgi-3.12.100.jar:?]
	at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:86) [bundleFile:?]
	at org.apache.felix.scr.impl.inject.BindParameters.getServiceObject(BindParameters.java:47) [bundleFile:?]
	at org.apache.felix.scr.impl.inject.methods.BindMethod.getServiceObject(BindMethod.java:664) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2308) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1805) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1788) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:435) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:325) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:294) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) [bundleFile:?]
	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) [bundleFile:?]
	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:920) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469) [org.eclipse.osgi-3.12.100.jar:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:906) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:892) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:959) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:732) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:1045) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:999) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) [bundleFile:?]
	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) [bundleFile:?]
	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:920) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469) [org.eclipse.osgi-3.12.100.jar:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:906) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:892) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:959) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:732) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:666) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:432) [bundleFile:?]
	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665) [bundleFile:?]
	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:338) [bundleFile:?]
	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:382) [bundleFile:?]
	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) [bundleFile:?]
	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) [bundleFile:?]
	at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) [bundleFile:?]
	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) [bundleFile:?]
	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) [bundleFile:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [osgi.core-6.0.0.jar:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [osgi.core-6.0.0.jar:?]
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [osgi.core-6.0.0.jar:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [osgi.core-6.0.0.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:168) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.Module.start(Module.java:467) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1614) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [org.eclipse.osgi-3.12.100.jar:?]

Error you’ve shown us doesn’t say anything about that.
It appears to be complaining about your broker Thing definition.