EXEC Binding - Pilight commands dont work

Hi i have a short question, i want to control my 433mhz sockets, it works in pimatic with shell execute , but didnt get it to work on the openhab 2.2 exec binding, already read all threads about EXEC Binding.

Switch on
pilight-send -p pollin -s 5 -u 4 -t
Switch of
pilight-send -p pollin -s 5 -u 4 -f

I created 2 seperate items but nothing seems to work.

A short hint would be nice .

thanks in advance

Ben

From Shell the Pi User execute the Command and from Binding the Openhab User execute the Command … I think the Openhab User has not the right to execute …

Try if

sudo pilight-send -p pollin -s 5 -u 4 -t

on shell works …

then you can authenticate the Openhab User to do sudo commands :slight_smile:

Thanks for the idea.
yes the command works in the bash with and without sudo
i tried with bash
sudo -u openhab /usr/local/bin/pilight-send -p pollin -s 9 -u 8 -t
works also.

How can i create a custom thing with with 2 items which are the states on and off.

if i create the exe binding with that commandline , it creates a thing with strange items / chanels. Output, Input, Exit Value, Running , Last Execution, no idea if that is the right way.

Can i create items without a thing ?

greets

if your Pi is heavily guarded and you’re 100% sure, you could give the openHAB user sudo privileges. But that’s highly not recommended! :wink:
So, if pilight-send works without sudo, then you should leave it at this.

What’s your code then? You can either use a rule or a thing or an item. :wink:

Did you read all exec binding threads :wink:

Setup your thing like shown there.
What is in the log then?

Thanks for the hint, i read it but i didnt understand it, is it realy that complicate to create a switch ? I realy need a rule to get that switch to work ?

My idea was… create a thing called Powerswitch-Shelf , and in that i create 2 items for ON and OFF, or iam thinking wrong ?

Why do you want to have two switches for one device toggle? Think of it like physical switch. it is just one switch, but two states ON and OFF.

So, for the start, just create one item:

Switch MyPilightSwitch	"Pilight Schalter"	{exec=">[OFF:pilight-send -p pollin -s 5 -u 4 -f] >[ON:pilight-send -p pollin -s 5 -u 4 -t]"}

perhaps you have to make sure, that pilight-send can be started without directory, or you just add it (assuming you’re using openHABian and pilight-send is compiled in ~):

Switch MyPilightSwitch	"Pilight Schalter"	{exec=">[OFF:/home/openhabian/pilight-send -p pollin -s 5 -u 4 -f] >[ON:/home/openhabian/pilight-send -p pollin -s 5 -u 4 -t]"}

CAREFUL

This one is exec1-syntax it won’t work with exec2 - please see below for more explanation on this!

1 Like

Thx binderth, we are getting closer, yes realy makes no sense to have to items for hat switch.

Mhh didnt worked , testet it with the full path to pilight send.

works like a charm in bash
/usr/local/bin/pilight-send -p pollin -s 9 -u 8 -t
/usr/local/bin/pilight-send -p pollin -s 9 -u 8 -f

Is there a log for checking - checked /opt/openhab2/userdata/logs , but nothing to find regarding the command execution.

I cant use that item in the Paper UI but shows up in HUBPanel , is there a thing needed to show up, what should i wrote in that things file to get it combind to my item ?

sorry for that silly questions, still a beginner :slight_smile:

greets ben

first of all: you don’t need anything for a item. It’s just there. especially handy if you need a “proxy item”, which just stands there as a variable - but doesn’t have an effect on anything. These items don’t have a binding definition in braces.
If you want to use a item with a binding you have to tell in the item definition the binding configuration in braces.

so. Some bindings need Things for items (most 2.x bindings need one).
The exec-binding doesn’t need one <= CAREFUL: This is false - see below for more info.

So, next step is looking into the logs, if you’re using openHABian, they’re here:

  • /var/log/openhab2/events.log // basically, everything on the eventbus is in here
  • /var/log/openhab2/openhab.log // here goes all INFO, WARNings, ERRORs, …

look in openhab.log and you’ll find something, why it didn’t work.

tried that live log in console with log:tail.

Shows only:
2:55:57.060 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘MyPilightSwitch’ received command ON
22:55:57.073 [INFO ] [smarthome.event.ItemStateChangedEvent] - MyPilightSwitch changed from OFF to ON

So no error, but still dont turn on and off , thats confusing.
in my default.items stands only:
Switch MyPilightSwitch “Pilight Schalter” {exec=">[OFF:/usr/local/bin/pilight-send -p pollin -s 9 -u 8 -f] >[ON:/usr/local/bin/pilight-send -p pollin -s 9 -u 8 -t]"}
Switch MyPilightSwitch2 “Pilight Schalter2” {exec=">[OFF:pilight-send -p pollin -s 9 -u 8 -f] >[ON:pilight-send -p pollin -s 9 -u 8 -t]"}

hmm. ok, this tells you, that the openHAB-item was changed and there was no ERROR while trying to execute. Then there’s something within your system configuration
There’s a pretty cool thread from Rich, please go there first:

if you’re still stuck, of course you can come back here anytime!

@bestgrafix @binderth I think this is the openhab 1 thing definition. So to used this kind of configuration install the legacy binding.

If you use Openhab 2 and the EXEC Binding 2 please follow the example.
When it works you can try to optimize, but i am not aware that it works as you like it to work.

Changes with the next version off the exec binding will reduce files and overhead and bring back openhab 1 binding like behavior, but for now the example is how it works and how you may get error logs to be able to traces problems.

I just did the test installing the legacy exec binding and it works as you like, no thing defining the command for on and off in the item. Before it did not.
So this is the legacy binding configuration and not the openhab 2 binding configuration.

1 Like

hmmm. I know, I messed around with the exec2-binding a year ago - but in my config, I’m not using exec1 it seems:

So, I’m curious, why the syntax works with me…? :thinking:

update:
Now I know! :wink: The items do nothing at all (as @Josar suggested correctly).
What I did obviously is to use “executeCommandline” in a rule, whenever an item changes (I’m even commented it in the rule itself!) :

rule "USB Hausnummer an/aus"
when
	Item USB_EG_Windfang_01 changed
then
	// Wegen exec 2.0 binding Syntax!
	if(USB_EG_Windfang_01.state == OFF) { executeCommandLine("/home/openhabian/usbstrom.sh 0 f 1") }
	if(USB_EG_Windfang_01.state == ON) { executeCommandLine("/home/openhabian/usbstrom.sh 0 o 1") }
end

With that comment I remember now: I was fed up with the complicated, warped exec2-thing configuration and so I did that Workaround. But I’m glad to hear that is taken care of in a new version of exec2

Perhaps this is a little better rule :wink:

The rule is thus also executed with the status NULL.
Status NULL is usually not available, since you have a persistence …

Try it, I’m not sure that the Syntax is 100% correct :wink:

rule "USB Hausnummer an/aus"
when
	Item USB_EG_Windfang_01 received command
then
	if(receivedCommand == OFF && USB_EG_Windfang_01.state != OFF) { executeCommandLine("/home/openhabian/usbstrom.sh 0 f 1") }
	if(receivedCommand == ON && USB_EG_Windfang_01.state != ON) { executeCommandLine("/home/openhabian/usbstrom.sh 0 o 1") }
end
1 Like

Thanks for your ideas. indeed my rule is a bit more complex, as I also read the status of each of the four USB-controlled power outlets and as the outlet has some minor flaws like it not always correctly toggles power and all… :wink:

1 Like

Thanks for all the help, got it to work, uninstalled EXEC Binding 2.X and installed version 1, now its working :slight_smile:

The command worked with the complete path to pilight-send and without.

2nd Question, i got Homematic IP at thome and use the HTTP Request to push the values in Pimatic, can i do that witth the HTTP Request Binding and how can i create a Diagramm in the HABPanel ?

1 Like

re Homematic IP: I don’t know this one and pimatic…

What I do now is diagrams in HABPanel. They are easy:

  1. configure persistence
  2. open up HABPanel and add a Dashboard and insert a “Chart” widget.
  3. use type RRD4j or n3-line-chart
  4. if n3-line-chart choose Service Provide (like ‘mysql’)
  5. configure Axis if needed and lastly
  6. insert your items as Series

Thanks for the info :slight_smile: I will try to setup the Persistence up - but looks complicated to me :wink:

I only want to draw a chart with temperature values , humidity and power consumption. Power consumption i already have as item from the tp link smart home binding (HS110 power plugs)

The Temp uns Humudity (values from homematicip-rest-api) i need to import , in pimatic it worked with a http request und push it in a variable, which would be an item in OpenHab2 i guess.

ah. ok - That’s pretty straight forward (both persistence and calling an API)

persistence: Just add one of your liking and configure in the .persistence configuration, which items should be persisted when => https://docs.openhab.org/configuration/persistence.html

calling an API: add the http-binding (https://docs.openhab.org/addons/bindings/http1/readme.html) and then you can add items with the API-calls as configuration:

Number Temperature "Temperature [%.1f °C]"   { http="<[http://YOURHOMEMATICIPURL)]" }

but i have to convert the string first, the api delivers me the devices in a list and i have to cut the values out example ?

3014F711A0000E970992A398 HmIP-STH Temperatur- und Luftfeuchtigkeitssensor lowbat(False) unreach(False) rssiDeviceValue(-57) rssiPeerValue(-64): actualTemperature(18.2) humidity(48)

Thats one line and i need only the value from acutal Temperature
python3 ./homematicip_cli.py --list-devices > hip-devics.log
tail hip-devics.log | grep ‘3014F711A0000E970992A398’ | grep -o -P ‘(?<=actualTemperature().*(?=) )’

then i get exact 18.2 and that value i need to get in to openhab, perhaps the HTTP Binding is not the right one?