Getting OpenHAB to switch a LED

Hy out there,

i am trying desperately to light a LED with my Raspberry3 running openhab2.
I have a Thing:
Thing exec:command:ledein “LED ein” [ command="sudo sh /etc/openhab2/scripts/ %2$ ]
I have an Item:
Switch ledein “LED” { channel=“exec:command:ledein:run”}
an a sitemap:
Switch item=ledein mappings=[ “ON”=“Ein”, “OFF”=“Aus” ]

I don´t have a LED giving light.

I´m shure its pretty easy,
but sorry , I’m german :wink:

EDIT led goes on by running the command line from the thing

Can you provide a little more information.

Also see here for assistance on how to ask a good question

What exec binding version are you using?

I don’t know and can’t find it in paper ui.
but i am able to switch some poweroutles

You should find it here.

Notice there are 2 exec bindings a 2.x and 1.x version.

Sorry, no version an i am too stupid ti insert a pic
It is exec binding by Karel Goderis

Use the console to show the binding and versions.

sudo openhab-cli console



Looking at your Things file you are missing a " at the end.

Thing exec:command:ledein “LED ein” [ command="sudo sh /etc/openhab2/scripts/ %2$ ]

Changed to add the missing "

Thing exec:command:ledein “LED ein” [ command="sudo sh /etc/openhab2/scripts/ %2$" ]

When the light turns on by running the command is the %2$ used or just sudo sh /etc/openhab2/scripts/ If the %2$ is needed then make sure you have the Regex transformation installed.

What errors do you see in the logs? You can view them by selecting openhab2 log viewer (front tail) from the web interface (same place you select to open PaperUI).

Good morning an thanks so far.

  • EXEC is 2.4.0

  • Eclipse SmartHome RegEx Transf is 0.10.0.oh240

  • I added the missing ", but LED is still dark.
    sudo sh /etc/openhab2/scripts/ works both ways, with and without %2$

  • in sudoers.tmp openhab and openhab2 are ALL=(ALL:ALL) ALL

  • ledein is chmod -x

  • Now to the Log: I am not able to get it. The place where I select PaperUI only has HomeBuilder, - Paper and Basic UI and HABPanel.

  • AND the last Entry in Event.log ( var/logs/openhab2) is from December 2018

  • BUT log:tail gives me a friendly
    08:37:32.542 [INFO ] [smarthome.event.ItemStateChangedEvent] - ledein changed from ON to OFF
    in green letters
    and a lot of Text in red concerning my fritzboxTR064 Binding ad some pink stuff because Name isn’t the same as in home …

Try removing the %2$ from the thing file.

How did you install OH, with apt-get or manually? The file should be openhab:openhab or openhab:openhabian.

What package did you select, minimal, simple, etc…? I have the standard package installed and it comes with OH by default (best I remember). If you go to sudo openhabian-config and use the tools I think you can add the front tail log.

not present, no Effect

I con´t remeber, would you recommend a fresh new new Installation ?
Where should I write openhab:openhab ?

see above, i dont know. but sudo openhabian-config doesn´t work, Befehl nicht gefunden

H102: Thanks for your Help so far !!!

Unless your fimilar with linux OS then I would start over with a fresh install so you have the openhabian config tool.

Here’s a link to the openhabian image. Use Etcher to flash the SD card and follow the documentation for setup.

Many Thanks.
I rember that i don´t wanted an openhabian Raspi but a Raspi with Jessie and Openhab.
Because of I want to get more familiar with Linux and like to use GPIO. Is this possible with the Image ?

If using the image it will be Stretch not Jessie but you can still use GPIO’s and it’s still linux.:wink: After you get it running, and familiar with OH, you can always get another SD card and go back to installing manually.

it´s in work

So finally is works.
I did a fresh install of Jessie an an apt-get install of openHAB.
I still can´t start the script via Openhab but the Quest is done:
A LED ist on when a poweroutlet is switched by openHAB and goes off when poweroutlet is switched off.
I will further try to switch LED by Openhab