Wireless sockets in openhab

rules
openhab2
items
Tags: #<Tag:0x00007f1e5ff11d80> #<Tag:0x00007f1e5ff11c40> #<Tag:0x00007f1e5ff11ab0>
(Jan) #1

Hey,

i want to turn on/off my wireless sockets via openhab on my RaspberryPi.
I can already turn them on/off with the Pi but my configuration with openhab does not work. I tried it first with the exec binding but now it want to do it with a rule. Does anyone know why it does not work?

default.items:
Switch TV_Steckdose “Fernseher”

mysite.sitemap:
sitemap mysite label=“Smarthome” {
Frame label=“Steckdosen” {
Switch item=TV_Steckdose label=“Lautsprecher” mappings=[ON=“An”, OFF=“Aus”]
}
}
default.rules
rule "TV_Steckdose Switch On"
when
Item TV_Steckdose changed to ON
then
sendCommand(bash /scripts/TV_AN.sh)
end

rule "TV_Steckdose Switch Off"
when
Item TV_Steckdose changed to OFF
then
sendCommand(bash /scripts/TV_AUS.sh)
end

0 Likes

(Angelos) #2

to execute a bash script from within a rule, read:


&
http://docs.openhab.org/addons/bindings/exec1/readme.html

0 Likes

(Jan) #3

hmm i dont use the exec binding

0 Likes

(Angelos) #4

hmmm then you can’t execute bash scripts from within a rule without it :slight_smile:

0 Likes

(Jan) #5

and if i write the command instead of the script?

“sendCommand(sudo /raspberry-remote/send 11000 1 1)”

0 Likes

(Angelos) #6

the sendCommand applies only to Items defined in openHAB.
it works like: WDim01_Dim.sendCommand(100) (this will send the value 100 to the WDim01 item)

If you want to call a bash script from within a rule, you need to use the Exec binding or the executeCommandLine directive/action

1 Like

(Josar) #7

@Takrem

hava a look at the following post and please use code fences for better readability.

0 Likes