OB3 - Switch by script

Hi Community,

it’s been a while I asked my last question but now, I need your help again.
I do have a couple of scripts like this run_x_on.sh. I added those to exec.whitelist and I created a Exce Thing. The script has 0 input parameters, can be executed straight. Permissions are on openhab:openhab and it’s executable.

Now, I like to have a Button / Switch / Toggle to execute that script. The Button, I like to add to a Page where I than have many of those.

I like to click the Button and except to execute my script but I’m not able to get this going.

What do I miss?

Looking at the docs, there is a run channel whose description is:

Send ON to execute the command

So link a Switch Item to that Channel and sending an ON command to that Item will cause the script to run.

How? It does not work.
What have I done? I created a new Thing (Exce Binding). One parameter is called “Command” and I entered opt/jwe_scripts/run_4_on.sh or sh opt/jwe_scripts/run_4_on.sh.

Than, I created, as you suggested, a linked Switch Item on Channel run. Settings are
Switch · Point and there, I tried everything but nothing worked.

Any idea? Youtube also has not videos showning how it works.

What’s in your logs?

You might do well to review the Getting Started Tutorial perhaps.

  1. Create and configure the Thing.
  2. Create a Switch Item
  3. Link the run Channel to that Switch Item
  4. Send that Switch Item an ON command
    a. Use a rule
    b. Use the toggle in the Item’s page
    c. Put a toggle on one of your MainUI pages
    d. Use a Switch element on a Sitemap
    e. etc.
  5. Look at openhab.log for errors and other useful information.

Thanks for comming back but still, no success.
My scripts are located in: /opt/jwe_scripts/
owern: openhab:openhab
permissions: all/everything
my command I like to execcute via OH3: sh run_4_on.sh
my whitelist:

  • run_4_on.sh
  • sh run_4_on.sh
  • ‘sh run_4_on.sh’
  • /opt/jwe_scripts/run_4_on.sh
  • sh /opt/jwe_scripts/run_4_on.sh
  • opt/jwe_scripts/run_4_on.sh
  • sh opt/jwe_scripts/run_4_on.sh

May you can help me with the settings for
myExcecBindingThing.Configuration.Command.value
myExcecBindingThing.Channels.runSwitch.LinkedSwitchItem.Profile.[xxxx].Command.value

I tried all combinations I can think of but nothing. In Log, I can see errors saying something like that:
Tried to execute ‘sh run_4_on.sh’, but it is not contained in whitelist.
My whitelist works, that I can garantee. Why, becaues chaning it will be taken into account by OH immediately




The script (run_4_on.sh)
#!/bin/bash

sh /opt/jwe_scripts/relaytoggle.sh 4 on 192.168.1.200 8080



My logs:

11:45:48.761 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘aaaaa5on_Ausfuhrung’ received command ON
11:45:48.767 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item ‘aaaaa5on_Ausfuhrung’ predicted to become ON
11:45:48.791 [WARN ] [ec.internal.ExecTransformationService] - Tried to execute ‘sh opt/jwe_scripts/run_4_on.sh’, but it is not contained in whitelist.
11:45:48.806 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘aaaaa5on_Ausfuhrung’ changed from OFF to ON
11:45:48.823 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘aaaaa5on_Ausfuhrung’ received command ON
11:45:48.834 [WARN ] [ec.internal.ExecTransformationService] - Tried to execute ‘sh opt/jwe_scripts/run_4_on.sh’, but it is not contained in whitelist.
11:45:48.842 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item ‘aaaaa5on_Ausfuhrung’ predicted to become ON
11:45:48.851 [WARN ] [ec.internal.ExecTransformationService] - Tried to execute ‘sh opt/jwe_scripts/run_4_on.sh’, but it is not contained in whitelist.
11:45:48.867 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘aaaaa5on_ZeitpunktderletztenAusfuhrung’ changed from 2022-06-24T11:44:32.356604+0200 to 2022-06-24T11:45:48.848043+0200
11:45:48.894 [WARN ] [ec.internal.ExecTransformationService] - Tried to execute ‘sh opt/jwe_scripts/run_4_on.sh’, but it is not contained in whitelist.
11:45:48.911 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘aaaaa5on_ZeitpunktderletztenAusfuhrung’ changed from 2022-06-24T11:45:48.848043+0200 to 2022-06-24T11:45:48.902652+0200
11:45:52.044 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘JagdWaffenschrankAlarm_Signalstarke’ changed from 2 to 1
11:

Don’t ask me why, the error is clear

11:50:55.274 [WARN ] [ec.internal.ExecTransformationService] - Tried to execute ‘sh /opt/jwe_scripts/run_4_on.sh’, but it is not contained in whitelist.
11:50:55.286 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘aaaaa5on_Ausfuhrung’ received command ON
11:50:55.293 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item ‘aaaaa5on_Ausfuhrung’ predicted to become ON
11:50:55.300 [WARN ] [ec.internal.ExecTransformationService] - Tried to execute ‘sh /opt/jwe_scripts/run_4_on.sh’, but it is not contained in whitelist.
11:50:55.433 [WARN ] [ec.internal.ExecTransformationService] - Tried to execute ‘sh /opt/jwe_scripts/run_4_on.sh’, but it is not contained in whitelist.
11:50:55.439 [WARN ] [ec.internal.ExecTransformationService] - Tried to execute ‘sh /opt/jwe_scripts/run_4_on.sh’, but it is not contained in whitelist.
1

but it works, the command sh /opt/jwe_scripts/run_4_on.sh works now.