OpenHAB2 exec Binding

execbinding
openhab2
beginners
Tags: #<Tag:0x00007f1e65b41858> #<Tag:0x00007f1e65b413f8> #<Tag:0x00007f1e65b40fe8>
(Josar) #1

After some time and struggle as a beginner with OpenHAB2 i managed to get a poweroutlet switch to work.
I found a lot of questions and Tutorials but somehow it was not easy and straight forward.

I started with this tutorial which is working out fine till the OpenHAB2 part starts.

After a lot of trouble this is my working solution.

// Path and File /etc/openhab2/items/powerplugs.items
Switch Power_Plug_Socket_B <poweroutlet>

// Path and File /etc/openhab2/sitemaps/powerplugs.sitemap
// Name of file and name of sitemap has to be the same
sitemap powerplugs label="Wireless Poweroutlets"
{
        Frame label="Poweroutlets"
        {
          Switch item=Power_Plug_Socket_B label="Power Plug B"
        }
}

// Path and File /etc/openhab2/rules/powerplugs.rules
/**
 * This is a rule to execute the ON and OFF command for poweroutlet B
 */
rule "Poweroutlet B"
        when
                Item Power_Plug_Socket_B received command
        then
        if (receivedCommand==ON ) {
            executeCommandLine("sudo /opt/raspberry-remote/send 10010 2 1")
        }
        else if (receivedCommand==OFF ) {
            executeCommandLine("sudo /opt/raspberry-remote/send 10010 2 0")
        }
end

This was the only configuratoin how i could get OpenHAB2 to execute the transmitt command.
Could someone who is familiar with OpenHAB2 comment on this!
Is this the proper way to do this and why?
How would this have to be done using things and channels and what is the advantage?

2 Likes

[SOLVED] Reading value from shell script, Tinkerforge Outdoor Weather Station
(Rich Koshak) #2

There are three ways to interact with external command line scripts and programs. None of them are any more right or wrong than the others. What you did is perfectly fine.

  1. executeCommandLine: your chosen solution is a good choice when initially trying to figure out the commands to send and debugging problems. This is because you can add a timeout to the call to executeCommandLine and see what the script being called is actually outputting. This is particularly helpful when the command doesn’t work. I personally just use the rules because of the lack of error reporting in the bindings.
rule "Poweroutlet B"
        when
                Item Power_Plug_Socket_B received command
        then
        var String results = ""
        if (receivedCommand==ON ) {
            results = executeCommandLine("sudo /opt/raspberry-remote/send 10010 2 1", 5000)
        }
        else if (receivedCommand==OFF ) {
            results = executeCommandLine("sudo /opt/raspberry-remote/send 10010 2 0", 5000)
        }
        logInfo("Power_Plug", "Results are: " + results)
end
  1. 1.x Exec Binding: this binding was developed for OH 1.x and compared to the 2.x version is simpler to configure and use. This is great to use for simple commands but if there are problems in the script no errors are reported. But once you get it working with 1, you can move the commands to the binding pretty easily.

    Switch Power_Plug_Socket_B { exec=">[ON:sudo /opt/raspberry-remote/send 10010 2 1] >[OFF:sudo /opt/raspberry-remote/send 10010 2 0" }

  2. 2.x Exec Binding: a lot of new concepts and ways to implement bindings changed in OH 2.x which unfortunately resulted in a 2.x version binding that is more complex to understand and use than the 1.x version. However, it does provide a little more capability including the ability to put the output and return value from the script into Items. But it does this by providing several Channels which map to different Items resulting in up to four Items for one script versus the simple single Item example above.

A 2.x version of your example would probably look something like this (NOTE: I have no direct experience with the 2.x version binding, I’m just going off the readme and how I would do it. My OH install is completely broken right now so I can’t test it):

Things:

Thing exec:command:remote-send [command="sudo /opt/raspberry-remote/send"]

Items:

Switch Power_Plug_Socket_B // same unbound Item as you have now
Switch Remote_Send { channel="exec:command:remote-send:run" }
String Remote_Send_Args { channel="exec:command:remote-send:input" }
String Remote_Send_Out { channel="exec:command:remote-send:output" }

Rule:


rule "Poweroutlet B"
when
  Item Power_Plug_Socket_B received command
then
  if(receivedCommand == ON)  Remote_Send_Args.postUpdate("10010 2 1")
  else Remote_Send_Args.postUpdate("10010 2 0")

  Remote_Send.sendCommand(ON)

  // wait for the command to complete
  while(Remote_Send.state != ON) Thread::sleep(100)

  logInfo("Power_Plug", "Resuts are: " + Remote_Send_Out.state)
end
2 Likes

(Josar) #3

Tried to reduce the switch to the minimum, but got stuck.

Things

exec:command:remote-send [
	command="sudo /opt/raspberry-remote/send 10010 2 %2$s", // %2$s = State of the input channel
	interval=0, // disables periodic execution
	autorun=true, // execute immediately every time the state of the input channel has changed
    autoupdate=true, // somehow sets return value from command Item State 
]

Items

 String Power_Plug_Socket_B <poweroutlet> { channel="exec:command:remote-send:input" }

Sitemap

sitemap powerplugs label="Wireless Poweroutlets"
{
        Frame label="Poweroutlets"
        {
          Switch item=Power_Plug_Socket_B label="Power Plug B"
        }
}

Which should work like that:

  1. User toggles switch
  2. Item state is changed to ON/OFF
  3. Thing executes command and “%2$s” gets replaced with ON/OFF or 1/0 ?

But the behaviour is as follows

13:48:45.296 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Power_Plug_Socket_B’ received command ON
13:48:45.298 [INFO ] [marthome.event.ItemStateChangedEvent] - Power_Plug_Socket_B changed from using pin 0
sending systemCode[10010] unitCode[2] command[0] to ON
13:48:45.766 [INFO ] [marthome.event.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to using pin 0
sending systemCode[10010] unitCode[2] command[0]

  1. User toggles switch
  2. Item state is changed to ON/OFF
  3. Thing executes command, but every time with “%2$s” always set to “0”
  4. The return value “using pin 0 sending systemCode[10010] unitCode[2] command[0]” of the command is written to the item State.

This solution seems to me to be the shortest and also OH2 compatible version.
But the question is how to get “%2$s” replaced with 1/0 or why is it always 0?

0 Likes

(Josar) #4

First of all, thank you for your extensive explanation.

If i use your example I get an Error.
The command to send does not contain the string which is in Remote_Send_Args.

21:24:25.661 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send_Args changed from "10010 2 1" to "100102 0"
21:24:25.669 [TRACE] [hab.binding.exec.handler.ExecHandler] - The command to be executed will be 'sudo /opt/raspberry-remote/send'

If i add “%2$s” there is an error:

21:19:19.722 [ERROR] [hab.binding.exec.handler.ExecHandler] - An exception occurred while formatting the command line with the current time and input values : 'Format specifier '%2$s''

If i add “%1$s”

 21:32:01.941 [TRACE] [hab.binding.exec.handler.ExecHandler] - The command to be executed will be 'sudo /opt/raspberry-remote/send Mon May 08 21:32:01 CEST 2017'

So it is replaced with a Time value.
Do you have an Idea why this happens?

0 Likes

(Rich Koshak) #5

Like I said above, I’ve not actually used the 2.0 version of the binding so there could be some errors or misunderstandings in my code above.

Where are you adding the %2$s? Reading the docs a little closer it does state that the %2$s is supposed to be replaced by the current state of the input channel. So it should properly go on the Thing definition. The correct version from my above posting should be:

Thing exec:command:remote-send [command="sudo /opt/raspberry-remote/send %2$s"]

The %1$s is supposed to give the current date so your example is expected.

Perhaps the input channel isn’t working? Are you running the snapshot? Perhaps the input channel is something added since the 2.0 release.

1 Like

Exec Transformation in Item
(steve1) #6

The documentation isn’t very clear (wrong?) about this, but the input channel is not triggered by an input item state update. It is triggered by a command to an item linked to the input channel (when autorun=true). The “%2$s” format specifier substitutes the value for the most recent command (which may or may not be the same as the state value). If no command was ever sent, I think it will currently throw an exception.

My understanding is that the binding developer is going to soon be making some significant changes to the way this works and will update the documentation accordingly.

Here’s a link to the code in case you want to take a look…

1 Like

(Josar) #7

Thank you very very much, this is the solution.
Me as an absolute beginner can not understand how things run with a documentation which does not include all elements an how they play together.

So a will recap this and Post it for other who are in the same position, please correct me if I am wrong.

The raspberry-remote has to be build, copied to an folder and the user privileges for openhab has to be set. Change the path to match the path to your raspberry-remote.

mkdir SourceCode
cd SourceCode
git clone https://github.com/xkonni/raspberry-remote.git
cd raspberry-remote
make send 

Add openhab to the usergroup gpio so it is allowed to acces the gpio of the RPI and then try to use the send command as user openhab. Replace the Adress and the Receiver Number to match your setting. The 1 at the end is the command for on, replace it with zero to shut off.

sudo adduser openhab gpio
sudo -u openhab SourceCode/raspberry-remote/send 10010 2 1

Then the exec Binding has to be installed via Paper UI or using the karaf console.

localhost:8080/paperui/index.html#/extensions

Search for exec and install the Binding. Also install regex transformation or open the console

 ssh -p 8101 openhab@localhost
 Password:habopen
 feature:install openhab-binding-exec
 feature:install openhab-transformation-regex
 logout

Now everything should be ready for setting up the OpenHAB UI.
We start with a thing to connect to the exec binding. This will contain the command without or with parts of the arguments. This file will be at “/etc/openhab2/things/exec.things”. I called it “exec” like the binding.

Thing exec:command:remote-send [
        command="/home/pi/SourceCode/raspberry-remote/send %2$s",
        interval=0,
        autorun=true]
  1. “exec:command” refers to the binding. “:remote-send” is an arbitrary name.
  2. “command=…” is the command line to execute, “%2$s” will be replaced by the command send to the input channel. Which connects an item to this thing.
  3. “interval=0” disables periodic execution
  4. “autorun=true” immediatly execute the command when the input channel got an command.

To connect the thing to the switch on the sitemap we need items. they the are located at “/etc/openhab2/items/powerplugs.items”

Switch Power_Plug_Socket_B <poweroutlet>

Switch Remote_Send { channel="exec:command:remote-send:run" }
String Remote_Send_Args { channel="exec:command:remote-send:input"}
String Remote_Send_Out { channel="exec:command:remote-send:output" }
  1. A switch item with an arbitrary name and the icon of a poweroutlet. This is used to define the layout of the UI later and store the state of the UI.
  2. A Switch item connected to the run channel of our thing, this will contain information about the status of the thing, like is it running or not.
  3. A String item connected to the input channel of our thing. This can contain the arguments which will replace the “%2$s” at the thing definition.
  4. A String item connected to the output channel of our thing, This will contain the return value of the executed command.

To have an visual representation of our switch we need an sitemap. This is located at “/etc/openhab2/sitemaps/powerplugs.sitemap” and has to be named same as the sitemap, here “powerplugs”.

sitemap powerplugs label="Wireless Poweroutlets"
{
        Frame label="Poweroutlets"
        {
          Switch item=Power_Plug_Socket_B label="Power Plug B"
        }
}

This is explained int detail int the Tutiorials. Major detail is “item=Power_Plug_Socket_B” this connects the UI to the switch item which was defined previously.

Last thing to do is defining some rules which triggers desired actions. The rules are located at “/etc/openhab2/rules/powerplugs.rules”.

rule "Poweroutlet B"
  when
    Item Power_Plug_Socket_B received command
  then
     if(receivedCommand == ON){
        Remote_Send_Args.sendCommand("10010 2 1")
     }else{
       Remote_Send_Args.sendCommand("10010 2 0")
     }

      // wait for the command to complete
      while(Remote_Send.state != OFF){
         Thread::sleep(500)
      }
      logInfo("Power_Plug", "Resuts are: \n" + Remote_Send_Out.state )
end

Rules are also explained in the Tutorials. Basic thing to get some action is “Remote_Send_Args.sendCommand(“10010 2 1”)” sending a command to the input channel. This will set the state of the item Remote_Send_Args to “10010 2 1” and the autorun defined in the thing will cause an execution of the command line. While the thing is in action the state of the item Remote_Send will reflect this by beeing “ON”. After the command is executed the item Remote_Send_Out will contain the last return value of the executed command.

A side note: in the the OpenHab terminal the items can be listet with the command “smarthome:items”.

openhab>smarthome:items
Power_Plug_Socket_B (Type=SwitchItem, State=OFF, Label=null, Category=poweroutlet)
Remote_Send (Type=SwitchItem, State=OFF, Label=null, Category=null)
Remote_Send_Args (Type=StringItem, State=10010 2 0, Label=null, Category=null)
Remote_Send_Out (Type=StringItem, State=using pin 0
sending systemCode[10010] unitCode[2] command[0], Label=null, Category=null)

Thank you rlkoshak and steve1 for your assistance. Hopefully this helps others understand how things work.

Additional:

[ERROR] [hab.binding.exec.handler.ExecHandler] - An exception occurred while formatting the command line with the current time and input values : 'Format specifier '%2$s''

This Error is displayed when the exec binding is triggered by .sendCommand to the run channel instead of the input channel.

3 Likes

(Alexander Kudryavtsev) #8

Hello All,
I started OH2 experience 2 days ago and the simplest thing I could imagine takes just enormous amount of time.
My objective is to simulate alarms.
F.e. I declare something as an alarm trigger and something as a siren (both based on files).
My configuration is exactly what was discussed above and it simply half-working!
The siren.sh was never triggered. loglevel TRACE for the EXEC handler never shows “Executing”.
Moreover after several tries the BASIC UI just stops refreshing the data.
If somebody knows the reason why, please advise the solution…

Thanks.

sitemap:
//sm
sitemap home label=“P12” {
Frame label=“ALARM” {
Text item=SENSOR1DATA label="Out: "
Text item=Siren label="SIREN: "
}
}

//rule
rule "Sensor1 On"
when
Item SENSOR1DATA changed to 150
then
logInfo(“Sensors”, “Sensor 1 was triggered”)
sendCommand(Siren, “ON”)
end

rule "Sensor1 Off"
when
Item SENSOR1DATA changed to 110
then
logInfo(“Sensors”, “Sensor 1 unset”)
sendCommand(Siren, “OFF”)
end

////things
Thing exec:command:sensor1 [command="/home/oh2/sensor1.sh", interval=5, timeout=5]
Thing exec:command:sirn [command="/home/oh2/siren.sh %2$s", interval=0, timeout=5, autorun=true]

//Items
String SENSOR1DATA “Value: [%s]” {channel=“exec:command:sensor1:output”}
String Siren “[%s]” {channel=“exec:command:sirn:input”, autoupdate=“true”}

2017-08-15 22:35:03.220 [INFO ] [lipse.smarthome.model.script.Sensors] - Sensor 1 unset
2017-08-15 22:35:13.011 [INFO ] [lipse.smarthome.model.script.Sensors] - Sensor 1 was triggered
2017-08-15 22:35:23.053 [INFO ] [lipse.smarthome.model.script.Sensors] - Sensor 1 unset

0 Likes

(Rich Koshak) #9

There is a bug right now that makes changed to rule triggers only work for enum types (e.g. ON, CLOSED, etc.).

Try just using changed and if statements to handle your cases and see if that makes a difference.

0 Likes

(Alexander Kudryavtsev) #10

Thank you for the idea Rich,
I’ve just solved the problem but the source is different.

Apparently, it has nothing to do with the “changed” syntax, it works just fine.
The problem was in the access rights.
Today, I saw your earlier post how to tackle the Exec Bind problems and one of actions was to check the user permissions.
First off, activate the log LEVEL

log:set TRACE org.openhab.binding.exec

[DEBUG] [hab.binding.exec.handler.ExecHandler] - Exec [ERROR]: ‘/home/oh2/siren.sh: line 2: /var/lib/openhab2/oh2/state.txt: No such file or directory’

In my siren.sh I used $HOME to do the output what’s wrong for another user unless one adapts permissions!
Solved.
One small hint:
The exec binding will never write the same string (the same data of the command) that has already been written:
https://github.com/openhab/openhab2-addons/blob/master/addons/binding/org.openhab.binding.exec/src/main/java/org/openhab/binding/exec/handler/ExecHandler.java:

                String previousInput = lastInput;
                lastInput = command.toString();
                if (lastInput != null && !lastInput.equals(previousInput)) {

Thank you again.

0 Likes

(Dominik B) #11

Hey and thank you for this detailed tutorial.

I copied your sources, so I have exactly the same. Unfortunately, the code is not sent when switching the Power Plug B in the app. The exec-binding is installed and moved to the adding file. Do I have to change the rights there ?Is there something else, I have to consider ?

Would be great if somebody could help me. Thank you !

0 Likes

(Thorsten Wolthausen) #12

I try to switch a powe plug with the sources from Josar.
But it does not work.
I use the openhabian.
When is use sudo su in terminal the command sudo ~/raspberry-remote/send 00001 2 1
works.
But only with this root rights. The openhabian user and the openhab can access to the command.

What should I do to fix ??

0 Likes

(Rich Koshak) #13
0 Likes

(Josar) #14

As openhab has no root you have to Grand it the access to the send command of the raspberry-remote by changing the sudoers. As it is stated in the description which my example is based on

http://www.forwardme.de/2016/11/24/433mhz-funksteckdosen-mit-raspberry-pi-und-openhab-schalten/

sudo mcedit /etc/sudoers

# User privilege specification
 root ALL=(ALL:ALL) ALL
 openhab ALL=NOPASSWD: /opt/raspberry-remote/send*
0 Likes

(Rich Koshak) #15

NOOOOOOOOOOO! Always use visudo to edit sudoers.

If you make one little syntax mistake you will all but brick your machine. The only way to recover is to boot or move your disk/sd card to another machine, mount that file system, and then edit out the errors you introduced. Even with visudo you can run into problems (e.g. I once lost my ssh connection while visudo was writing out to the sudoers file leaving it corrupted).

See the following for how to change the editor if you don’t like vi:

You want to use visudo because it makes sure there are no syntax errors in a temp file before it copies your changes over to the active file. So if you have an error you are not locked out of your machine.

0 Likes

(Thorsten Wolthausen) #16

Hello Josar,

thanks for your answer

I did’nt have success with the powerplug access yet.

I added my config and log files.
There are errors.

By changing the sudoers file the system crashed two times.
So I want to fix the errors in config first and then get to the wrong access rights.

  • I dont’t know if the path to the send command is right.
    I cant find it in dir opt at my system

  • which user I have to edit in sudoers?
    the user on my pi is openhabian.
    Should I edit openhab or openhabian?

looking forward hearing from you

Thorsten

meine.items

Switch Power_Plug_Socket_B

Switch Remote_Send { channel=“exec:command:remote-send:run” }
String Remote_Send_Args { channel=“exec:command:remote-send:input”}
String Remote_Send_Out { channel=“exec:command:remote-send:output” }

powerplug.rules

rule "Poweroutlet B"
when
Item Power_Plug_Socket_B received command
then
if(receivedCommand == ON){
Remote_Send_Args.sendCommand(“00001 2 1”)
}else{
Remote_Send_Args.sendCommand(“00001 2 0”)
}

  // wait for the command to complete
  while(Remote_Send.state != ON){
     Thread::sleep(500)
  }

logInfo(“Power_Plug”, “Results are: \n” + Remote_Send_Out.state)
end

meine.sitemap

sitemap powerplugs label=“Wireless Poweroutlets”
{
Frame label=“Poweroutlets”
{
Switch item=Power_Plug_Socket_B label=“Power Plug B”
}
}

meine.things

Thing exec:command:remote-send [
command=“sudo /opt/raspberry-remote/send %2$s”,
interval=0,
autorun=true,
]

openhab.log

2017-10-05 19:03:46.910 [INFO ] [panel.internal.HABPanelDashboardTile] - Stopped HABPanel
2017-10-05 19:03:46.936 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Stopped Paper UI
2017-10-05 19:03:47.025 [INFO ] [basic.internal.servlet.WebAppServlet] - Stopped Basic UI
2017-10-05 19:03:47.086 [INFO ] [.dashboard.internal.DashboardService] - Stopped dashboard
2017-10-05 19:04:42.698 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'meine.items’
2017-10-05 19:04:42.812 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.items’
2017-10-05 19:04:46.860 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘meine.rules’ has errors, therefore ignoring it: [15,70]: missing ‘)’ at ‘")\r\nend\r\n’

2017-10-05 19:04:48.785 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.rules’
2017-10-05 19:04:51.019 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.sitemap’
2017-10-05 19:04:51.060 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'meine.sitemap’
2017-10-05 19:04:52.052 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'exec.things’
2017-10-05 19:04:52.085 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘meine.things’ has errors, therefore ignoring it: [5,1]: mismatched input ‘]’ expecting RULE_ID

2017-10-05 19:04:53.786 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at http://192.168.1.81:8080
2017-10-05 19:04:54.006 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://192.168.1.81:8443
2017-10-05 19:04:54.532 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2017-10-05 19:04:54.606 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2017-10-05 19:04:54.671 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2017-10-05 19:05:30.611 [WARN ] [sitemap.internal.SitemapProviderImpl] - Filename meine.sitemap does not match the name powerplugs of the sitemap - please fix this as you might see unexpected behavior otherwise.
2017-10-05 19:05:31.248 [WARN ] [sitemap.internal.SitemapProviderImpl] - Filename meine.sitemap does not match the name powerplugs of the sitemap - please fix this as you might see unexpected behavior otherwise.
2017-10-05 19:05:34.117 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate command ‘00001 2 1’ for item ‘Remote_Send_Args’ to handler for channel ‘exec:command:remote-send:input’, because no thing with the UID ‘exec:command:remote-send’ could be found.
2017-10-05 19:05:34.121 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘00001 2 1’ for item ‘Remote_Send_Args’ to handler for channel ‘exec:command:remote-send:input’, because no thing with the UID ‘exec:command:remote-send’ could be found.
2017-10-05 19:05:34.554 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate command ‘00001 2 0’ for item ‘Remote_Send_Args’ to handler for channel ‘exec:command:remote-send:input’, because no thing with the UID ‘exec:command:remote-send’ could be found.
2017-10-05 19:05:34.559 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘00001 2 0’ for item ‘Remote_Send_Args’ to handler for channel ‘exec:command:remote-send:input’, because no thing with the UID ‘exec:command:remote-send’ could be found.

events.log

2017-10-05 19:03:47.369 [temChannelLinkRemovedEvent] - Link ‘Remote_Send_Out => exec:command:remote-send:output’ has been removed.
2017-10-05 19:03:47.371 [temChannelLinkRemovedEvent] - Link ‘Remote_Send_Args => exec:command:remote-send:input’ has been removed.
2017-10-05 19:03:47.373 [temChannelLinkRemovedEvent] - Link ‘Remote_Send => exec:command:remote-send:run’ has been removed.
2017-10-05 19:04:51.732 [ItemChannelLinkAddedEvent ] - Link ‘Remote_Send_Out-exec:command:remote-send:output’ has been added.
2017-10-05 19:04:51.734 [ItemChannelLinkAddedEvent ] - Link ‘Remote_Send_Args-exec:command:remote-send:input’ has been added.
2017-10-05 19:04:51.736 [ItemChannelLinkAddedEvent ] - Link ‘Remote_Send-exec:command:remote-send:run’ has been added.
2017-10-05 19:05:33.792 [ItemCommandEvent ] - Item ‘Power_Plug_Socket_B’ received command ON
2017-10-05 19:05:33.838 [ItemStateChangedEvent ] - Power_Plug_Socket_B changed from NULL to ON
2017-10-05 19:05:34.120 [ItemCommandEvent ] - Item ‘Remote_Send_Args’ received command 00001 2 1
2017-10-05 19:05:34.126 [ItemStateChangedEvent ] - Remote_Send_Args changed from NULL to 00001 2 1
2017-10-05 19:05:34.529 [ItemCommandEvent ] - Item ‘Power_Plug_Socket_B’ received command OFF
2017-10-05 19:05:34.539 [ItemStateChangedEvent ] - Power_Plug_Socket_B changed from ON to OFF
2017-10-05 19:05:34.558 [ItemCommandEvent ] - Item ‘Remote_Send_Args’ received command 00001 2 0
2017-10-05 19:05:34.565 [ItemStateChangedEvent ] - Remote_Send_Args changed from 00001 2 1 to 00001 2 0

0 Likes

(Josar) #17

I updated my post and added some more information. I will try to set this up as explained in the next days. But i think it should work like that.

The thing had an additional comma after autorun=true. It did not provoke errors when i used it like that but now it does. I just removed the comma and all formating so it is one line. And the error was solved.

The sitemap file has to have the same name as the sitemap in the file.

To find out which user you have to add to the gpio group just search who owns openhab by executing following ps command. I think no additional editing of sudoers should be required.

ps -ef | grep open
openhab    424     1  0 18:31 ?        00:00:00 /bin/bash /usr/share/openhab2/runtime/bin/karaf server
...

Is the user openhab or openhabian?

0 Likes

OpenHAB Exec Binding explained in detail on 433MHz radio transmitter example
(Josar) #18

@rlkoshak Could you please hint to where this documented.

0 Likes

(Rich Koshak) #19

https://docs.openhab.org/addons/bindings/exec/readme.html#thing-configuration

the current State of the input channel (see below, example: %2$s)

0 Likes