Oh-button used to launch rule doesn't work remotly

Hi,

I have a widget which contains a button which iniates a rule. When I launch this when i’m connected to my local network it works fine. When i launch it when im logged on via myopenhab.org it gives an error message.

uid: Waterput_Overzicht
tags: []
props:
  parameters:
    - description: Titel
      label: Titel
      name: title
      required: false
      type: TEXT
    - description: Kleur HEX of rgba
      label: Achtergrondkleur
      name: bgcolor
      required: false
      type: TEXT
    - context: item
      description: Item voor laatste update
      label: Update tijdstip
      name: item_update
      required: false
      type: TEXT
    - context: item
      description: Item voor waterlevel
      label: Waterlevel
      name: item_water
      required: true
      type: TEXT
    - context: item
      description: Item voor afstand tot water
      label: Afstand tot water
      name: item_water_distance
      required: true
      type: TEXT
    - context: rule
      description: Rule voor lees waterlevel
      label: Rule voor request waterlevel
      name: rule
      required: true
      type: TEXT
  parameterGroups: []
timestamp: Jan 19, 2022, 5:52:40 PM
component: f7-card
config:
  style:
    noShadow: false
    box-shadow: 5px 5px 10px 1px rgba(0,0,0,0.1)
    border-radius: var(--f7-card-expandable-border-radius)
    background-color: "=props.bgcolor ? props.bgcolor : themeOptions.dark === 'dark' ? 'DimGrey' : 'GhostWhite'"
    height: auto
    width: auto
    min-width: 273px
    max-width: 300px
slots:
  header:
    - component: Label
      config:
        text: "=props.title ? props.title : ''"
        style:
          font-size: 20px
          margin-top: 0px
  default:
    - component: f7-card-content
      slots:
        default:
          - component: f7-row
            config:
              style:
                position: relative
                height: 30px
            slots:
              default:
                - component: f7-col
                  slots:
                    default:
                      - component: f7-chip
                        config:
                          iconF7: alarm
                          text: =items[props.item_update].displayState
                          style:
                            margin-bottom: 10px
                            font-size: 16px
                            --f7-chip-bg-color: rgba(255, 255, 255, 0)
                          iconColor: "=themeOptions.dark === 'dark' ? 'blue' : 'deeporange'"
                          iconSize: 20
          - component: f7-row
            config:
              style:
                position: relative
                height: 30px
            slots:
              default:
                - component: f7-col
                  slots:
                    default:
                      - component: f7-chip
                        config:
                          iconF7: drop
                          text: =items[props.item_water].displayState + ' ('+ items[props.item_water_distance].displayState +')'
                          style:
                            margin-bottom: 10px
                            font-size: 16px
                            --f7-chip-bg-color: rgba(255, 255, 255, 0)
                          iconColor: "=themeOptions.dark === 'dark' ? 'blue' : 'deeporange'"
                          iconSize: 20
                - component: f7-col
                  slots:
                    default:
                      - component: oh-button
                        config:
                          text: Lees
                          outline: true
                          action: rule
                          actionRule: =props.rule
                          style:
                            margin-left: 20px
                            width: 90px
                            --f7-button-border-color: "=themeOptions.dark === 'dark' ? '#2196f3' : rgba(221, 110, 15, 0.24)"
                            color: "=themeOptions.dark === 'dark' ? '#2196f3' : 'deeporange'"

afbeelding

How can i fix this, a possible solution could be to use a switch to initiate the rule, but that is a workaround

A very simple work around is to use a proxy item. The button can send a command to an item and the rule can trigger on the event that the item receives a command.

However, I think it’s also important to track down what’s going on here because this may impact more users than just you.

  • Are you sure the rule fails to trigger (it might run but not produce the expected results when triggered remotely depending on the content of the rule)?
  • Does the button work if you try to trigger some different rule while logged in through myopenhab?
  • Are there any errors in the OH logs when this happens?
  • Have you tried this with different browsers?
  • Do you see this problem both in desktop browsers and in the mobile app?
  • Do you see any errors in the browser’s console when the rule fails to run?

Are you logged in as an admin user in MainUI when you experience the error. The default security configuration only allows interaction with Items when not logged in or logged in as a normal user.

Open the console in the browser and show us if more information is posted there. If it’s a permission type error that’s probably the reason.

If you want this widget to work for all users, you’ll need to use an Item like Justin suggests.

Are you sure the rule fails to trigger (it might run but not produce the expected results when triggered remotely depending on the content of the rule)?
Yes, tested with a very simple rule and got the same result. Locally it works fine, via myopenhab i get the error.
Does the button work if you try to trigger some different rule while logged in through myopenhab?
No, get the same resullt.
Are there any errors in the OH logs when this happens?
Yes this is the eror

17:42:07.625 [WARN ] [rs.impl.WebApplicationExceptionMapper] - javax.ws.rs.ClientErrorException: HTTP 415 Unsupported Media Type
	at org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:117)
	at org.apache.cxf.jaxrs.utils.ExceptionUtils.toHttpException(ExceptionUtils.java:168)
	at org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:514)
	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:181)
	at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544)
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307)
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:494)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918)
	at java.base/java.lang.Thread.run(Thread.java:834)

Have you tried this with different browsers?
I have tested with firefox, chrome & edge
Do you see this problem both in desktop browsers and in the mobile app?
Yes, same issue occurs also in the mobile app. Works when im connected locally, doesn’t work if remote url is used
Do you see any errors in the browser’s console when the rule fails to run?
Yes,

Im running on openHAB 3.0.2 release build.

I have the problem when i’m not logged in and if i’m logged in as admin

In that case, your issue appears to be similar to an issue that has already been resolved:

It looks like you need to upgrade your OH to get the fix, or just use the workaround.

Thanks, upgrade fixed the issue