Seite 2 von 3

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 07:46
von lenschith
habe das noch mal ausgebessert. Aber leider bleibt der Fehler bestehen.

Code: Alles auswählen

2024-01-11 07:53:58.244 [INFO ] [mation.script.ui.Script_Notification] - Variable einlesen: Empf_Liste: [object Object],[object Object],[object Object],[object Object] Status: Info Icon: fish1 sText: TEST Aquarium unterGruppe: Aquarium

2024-01-11 07:53:58.248 [INFO ] [mation.script.ui.Script_Notification] - Name: notificationStefan_Aquarium (Type=SwitchItem, State=ON, Label=StefanNotification_Aquarium, Category=switch, Groups=[gNotification, gNotificationStefan])

2024-01-11 07:53:58.261 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:

org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property "Name" from undefined

	at <js>.:program(<eval>:17) ~[?:?]

	at org.graalvm.polyglot.Context.eval(Context.java:399) ~[bundleFile:?]

	at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[bundleFile:?]

	at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:426) ~[bundleFile:?]

	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262) ~[java.scripting:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[bundleFile:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[bundleFile:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[bundleFile:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[bundleFile:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:71) ~[?:?]

	at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:68) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1039) ~[?:?]

	at <js>.runRule(@openhab-globals.js:2) ~[?:?]

	at <js>.:program(<eval>:3) ~[?:?]

	at org.graalvm.polyglot.Context.eval(Context.java:399) ~[bundleFile:?]

	at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[bundleFile:?]

	at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:426) ~[bundleFile:?]

	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262) ~[java.scripting:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[bundleFile:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[bundleFile:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[bundleFile:?]

	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[bundleFile:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:71) ~[?:?]

	at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]

	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:68) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) ~[?:?]

	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1039) ~[?:?]

	at org.openhab.core.automation.rest.internal.RuleResource.runNow(RuleResource.java:381) ~[?:?]

	at org.openhab.core.automation.rest.internal.RuleResource.runNow(RuleResource.java:398) ~[?:?]

	at jdk.internal.reflect.GeneratedMethodAccessor295.invoke(Unknown Source) ~[?:?]

	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]

	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[bundleFile:3.6.2]

	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ~[bundleFile:3.6.2]

	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) ~[bundleFile:3.6.2]

	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) ~[bundleFile:3.6.2]

	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[bundleFile:3.6.2]

	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) ~[bundleFile:3.6.2]

	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) ~[bundleFile:3.6.2]

	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) ~[bundleFile:3.6.2]

	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:265) ~[bundleFile:3.6.2]

	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) ~[bundleFile:3.6.2]

	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) ~[bundleFile:3.6.2]

	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) ~[bundleFile:3.6.2]

	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:225) ~[bundleFile:3.6.2]

	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:304) ~[bundleFile:3.6.2]

	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:217) ~[bundleFile:3.6.2]

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) ~[bundleFile:4.0.4]

	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:279) ~[bundleFile:3.6.2]

	at org.ops4j.pax.web.service.spi.servlet.OsgiInitializedServlet.service(OsgiInitializedServlet.java:102) ~[bundleFile:?]

	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1656) ~[bundleFile:9.4.52.v20230823]

	at org.ops4j.pax.web.service.spi.servlet.OsgiFilterChain.doFilter(OsgiFilterChain.java:100) ~[bundleFile:?]

	at org.ops4j.pax.web.service.jetty.internal.PaxWebServletHandler.doHandle(PaxWebServletHandler.java:320) ~[?:?]

	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:234) ~[bundleFile:9.4.52.v20230823]

	at org.ops4j.pax.web.service.jetty.internal.PrioritizedHandlerCollection.handle(PrioritizedHandlerCollection.java:96) ~[?:?]

	at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:722) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.Server.handle(Server.java:516) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487) ~[bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) [bundleFile:9.4.52.v20230823]

	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) [bundleFile:9.4.52.v20230823]

	at java.lang.Thread.run(Thread.java:840) [?:?]

2024-01-11 07:53:58.277 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Script_Notification' failed: org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property "Name" from undefined
Screenshot 2024-01-11 075519.png
Screenshot 2024-01-11 081329.png

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 08:49
von Harka
jup, habe noch Fehler gefunden ;)
NotifikationFehler2Forum.png
Da ist noch 2 mal zu viel Ballast an Bord. Aus welchem Grund auch immer, muss das get_state_of_item auch anders aufgerufen werden.
Ich prüfe gleich noch ob das InlineScript prinzipiell funktioniert. Ist ja bisher auch nur graue Theorie.
E: funktioniert bei mir

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 09:25
von lenschith
OK. Error kommt jetzt keiner aber das Objektfeld bleibt immer noch leer.

Code: Alles auswählen

2024-01-11 09:19:35.998 [INFO ] [tomation.script.ui.Notification_Test] - Script_Notification aufgerufen

2024-01-11 09:19:36.004 [INFO ] [mation.script.ui.Script_Notification] - Variable einlesen: Empf_Liste: [object Object],[object Object],[object Object],[object Object] Status: Info Icon: fish1 sText: TEST Aquarium unterGruppe: Aquarium

2024-01-11 09:19:36.007 [INFO ] [mation.script.ui.Script_Notification] - Name: notificationStefan_Aquarium (Type=SwitchItem, State=ON, Label=StefanNotification_Aquarium, Category=switch, Groups=[gNotification, gNotificationStefan])

Code: Alles auswählen

var unterGruppe, sText, Icon, Status, Empf_Liste, i, j, SuchName, Mailadresse;


unterGruppe = ctx['uGruppe'];
sText = ctx['Text'];
Icon = ctx['Icon'];
Status = ctx['Status'];
Empf_Liste = [{'Name': 'stefan', 'Mail': 'stefan@xyz.com'}, {'Name': 'lisa', 'Mail': 'lisa@xyz.com'}, {'Name': 'horst', 'Mail': 'horst@xyz.com'}, {'Name': 'anne', 'Mail': 'anne@xyz.com'}];
console.info((['','Variable einlesen: ','Empf_Liste: ',Empf_Liste,' Status: ',Status,' Icon: ',Icon,' sText: ',sText,' unterGruppe: ',unterGruppe].join('')));
var i_list = items.getItem('gNotification').members;
for (var i_index in i_list) {
  i = i_list[i_index];
  if (i.name.indexOf(unterGruppe) + 1 > 0) {
    console.info(('Name: ' + String(i)));
    for (var j_index in Empf_Liste) {
      j = Empf_Liste[j_index];
      SuchName = j['Name'];
      if (i.name.indexOf(SuchName) + 1 > 0) {
        if (i.state == 'ON') {
          Mailadresse = j['Mail'];
          actions.NotificationAction.sendNotification(Mailadresse, sText, Icon, Status);
        }
      }
    }
  }
}

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 09:49
von Harka
ne, das ist nicht leer sondern der JSON-Wert kann nur nicht so ohne weiteres angezeigt werden. Setzt mal ein Log für Mailadresse direkt über dem InlineScript.

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 10:27
von lenschith
er geht nicht in die Schleife rein.

Code: Alles auswählen

2024-01-11 10:17:05.646 [INFO ] [mation.script.ui.Script_Notification] - Variable einlesen: Empf_Liste: [object Object],[object Object],[object Object],[object Object] Status: Info Icon: fish1 sText: TEST Aquarium unterGruppe: Aquarium

2024-01-11 10:17:05.650 [INFO ] [mation.script.ui.Script_Notification] - SuchName: stefan

2024-01-11 10:17:05.652 [INFO ] [mation.script.ui.Script_Notification] - keine Notification!
Screenshot 2024-01-11 102528.png

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 10:47
von Harka
Du beginnst in den Items den Namen mit Großbuchstaben. Entweder Du machst das hier in 'Name' auch oder arbeitest noch ein lower case mit ein.
Stefan ungleich stefan

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 11:01
von lenschith
oh, man. da hätte ich ja auch selbst drauf kommen können ich Trottel.
Aber jetzt klappts.

Vielen Dank

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 11:55
von Harka
Super, und ja - das hätte mir auch früher auffallen können. Auf jeden Fall hat sich das krankheitsbedingte zu Hause bleiben schon mal gelohnt ^^

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 12:01
von lenschith
Hab da noch ne dumme Frage. Aus dem Block für die Rule könnte man doch auch eine Block Library machen?
Hat da evtl. noch jemand eine Idee. Da habe ich mich bisher nur wenig damit beschäftigt. Bisher nur Copy und Paste.
Screenshot 2024-01-11 112439.png

Re: Notification über openHAB App

Verfasst: 11. Jan 2024 12:45
von Harka
Können schon, aber ... Ist schnell angelegt und dank Cross-Rule-Copy macht das nicht mehr sooo viel Sinn. Da fände ich ein Notifications-Block der alle Parameter (inkl. Mail) unterstütz, fast nützlicher.