Getting OpenHAB to switch a LED


(Andreas Hartmann) #1

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/ledein.sh %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


(CM6.5 H102) #2

Can you provide a little more information.

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


(CM6.5 H102) #4

What exec binding version are you using?


(Andreas Hartmann) #5

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


(CM6.5 H102) #6

You should find it here.

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


(Andreas Hartmann) #7

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


(CM6.5 H102) #8

Use the console to show the binding and versions.

sudo openhab-cli console

then

bundle:list


(CM6.5 H102) #9

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

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

Changed to add the missing "

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

When the light turns on by running the command is the %2$ used or just sudo sh /etc/openhab2/scripts/ledein.sh? 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).


(Andreas Hartmann) #10

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/ledein.sh 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 …


(CM6.5 H102) #11

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.


(Andreas Hartmann) #12

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


(Andreas Hartmann) #13

H102: Thanks for your Help so far !!!


(CM6.5 H102) #14

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.

https://bintray.com/openhab/bin/download_file?file_path=openhabianpi-raspbian-201804031720-gitdba76f6-crc9e93c3eb.img.xz


(Andreas Hartmann) #15

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 ?


(CM6.5 H102) #16

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.


(Andreas Hartmann) #17

it´s in work
THX


(Andreas Hartmann) #18

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