@muhackl666 try to install the exec binding and the regex transformation from paper ui, again.
I encountered a problem with karaf and paper ui Installation.
Please clear the log then restart and post your full log.
@muhackl666 try to install the exec binding and the regex transformation from paper ui, again.
I encountered a problem with karaf and paper ui Installation.
Please clear the log then restart and post your full log.
I deinstalled the regex binding and reinstalled it - both via paper ui this time. I also installed exec transformation.
I deinstalled and reinstalled the exec binding. And this is the log:
21:58:32.930 [INFO ] [smarthome.event.ExtensionEvent ] - Extension ‘binding-exec’ has been installed.
21:58:32.994 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - ‘exec:command:remote-send’ changed from UNINITIALIZED to INITIALIZING
21:58:33.012 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - ‘exec:command:remote-send’ changed from INITIALIZING to ONLINE
21:58:46.633 [INFO ] [smarthome.event.ExtensionEvent ] - Extension ‘transformation-regex’ has been installed.
21:58:57.561 [INFO ] [smarthome.event.ExtensionEvent ] - Extension ‘transformation-exec’ has been installed.
21:59:54.450 [INFO ] [del.core.internal.ModelRepositoryImpl] - Refreshing model 'exec.things’
21:59:54.505 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing ‘exec:command:remote-send’ has been updated.
22:00:42.946 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Remote_Send’ received command ON
22:00:42.993 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send changed from NULL to ON
22:00:43.013 [ERROR] [nhab.binding.exec.handler.ExecHandler] - An exception occurred while formatting the command line with the current time and input values : 'Format specifier ‘%2$s’'
22:00:43.043 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send changed from ON to OFF
@muhackl666 i dont see where you pressed a switch in the log. As there is no output logged from the rules and also no state change from the switches.
How does Remote_Send
gets triggered to change to ON?
When the input channel in this case Remote_Send_Args
is not set before triggering the execution there will be this error.
What is shown in the log when you press a switch?
PS: please use the icons above the writing field to format your code or log.
```
your code goes here
```
Exactly this is shown, when I switch the switch in basic ui. The switch goes to the right and after that automatically back to the left (off). In the log, that’s everything that happens:
19:41:52.043 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Remote_Send’ received command ON
19:41:52.060 [ERROR] [nhab.binding.exec.handler.ExecHandler] - An exception occurred while formatting the command line with the current time and input values : 'Format specifier ‘%2$s’'
19:41:52.092 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send changed from OFF to ON
19:41:52.147 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send changed from ON to OFF
I at least miss one of this outputs in the logs.
logInfo("Power_Plugs", "Switch Socket "+ num +" to " + plug.state )
...
logInfo("Power_Plug", "Result:" + Remote_Send_Out.state )
I’m using the Poweplugs example.
exec.things
Thing exec:command:remote-send [
command="/opt/raspberry-remote/send %2$s",
interval=0,
autorun=true]
powerplug.rules
rule "Poweroutlet B"
when
Item Power_Plug_Socket_B received command
then
// wait for transmitter to be free
// State will be NULL if not used before or ON while command is executed
while(Remote_Send.state == ON){
Thread::sleep(500)
}
if(receivedCommand == ON){
Remote_Send_Args.sendCommand("11111 1 1")
}else{
Remote_Send_Args.sendCommand("11111 1 0")
}
// wait for the command to complete
while(Remote_Send.state != OFF){
Thread::sleep(500)
}
logInfo("Power_Plug", "Result:" + Remote_Send_Out.state )
end
powerplug.items
Switch Power_Plug_Socket_A <poweroutlet>
Switch Power_Plug_Socket_B <poweroutlet>
Switch Power_Plug_Socket_AB <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" }
powerplug.sitemap
sitemap powerplugs label="Wireless Poweroutlets"
{
Frame label="Poweroutlets"
{
Switch item=Power_Plug_Socket_A label="Power Plug A"
Switch item=Power_Plug_Socket_B label="Power Plug B"
Switch item=Power_Plug_Socket_AB label="Power Plug AB"
}
}
When I do:
sudo -u pi /opt/raspberry-remote/send 11111 1 1
the power outlet switches on. With 0 at the end it switches off.
When I do:
sudo -u openhab /opt/raspberry-remote/send 11111 1 1
the power outlet switches on. With 0 at the end it switches off.
Exactly.
It’s a Raspberry Pi 3 with the latest Raspbian Stretch and Openhab installed like described here: https://docs.openhab.org/installation/linux.html
via
echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list
and
sudo apt-get install openhab2
and even
sudo apt-get install openhab2-addons
@muhackl666 only thing i can advise now is a fresh install of openhab or the whole pi. I have no further ideas.
But why does your switch automatically turn off again?
And what is the version of your openhab? Mine is
dpkg --list | grep openhab
ii openhab2 2.2.0-1 all openhab2
So I set up another raspberry pi3 - everything totally freshly.
And it works fine - at least in basic ui.
So something must have been misconfigured in my previous setup.
Regarding paper ui, it looks like this:
The switch can’t be used. Any hints?
Paper UI is a config and maybe testing tool. Not a user UI.
To use you need a Basic UI or an Habpanel or one of the others i don´t now of.
No problem. I’ll get along. You helped me a lot and openHAB is now a lot more useful for me.
Many thanks again.
Hey Josar,
thanks for your great tutorial - I’ve been searching for a way to control my powerplugs via Alexa and openHAB for a long time. Your solution works fine for me.
But sometimes my transmitter signal gets lost or isn’t recognized by the receiver. I’d like to send every command multiple times to make sure the digital and physical state of the device are equal. What is the smartest way to do this? In this thread I found a few helpful things but I don’t know how to put them together.
I’m not sure if this works if I set the thing’s autorun to false:
rule "Poweroutlet B"
when
Item Power_Plug_Socket_B received command
then
var i = 0
// wait for transmitter to be free
// State will be NULL if not used before or ON while command is executed
while(Remote_Send.state == ON){
Thread::sleep(500)
}
if(receivedCommand == ON){
Remote_Send_Args.sendCommand("11111 1 1")
}else{
Remote_Send_Args.sendCommand("11111 1 0")
}
// send the command e.g. 5 times
while((i=i+1) < 6){
Remote_Send.sendCommand(ON)
// wait for the command to complete
while(Remote_Send.state != OFF){
Thread::sleep(500)
}
}
logInfo("Power_Plug", "Result:" + Remote_Send_Out.state )
end
I know that I could just edit and test the rule until it works but I’d like to get into openHAB and understand how it’s working.
Best regards
Jannis
Thank you @Josar for this great thread.
I’m up and running now, except for one thing, for which I would really appreciate your input.
I’m using the exec binding to control my Air Conditioning unit (AC) through a WEB interface.
With the control (aka POST) bit in place, how would you go about getting polled (aka GET) values returned by a bash script into the exec:command framework?
(My current script returns “0” or “1” for OFF or ON, for temperature values strings like “23.5” are returned.)
I want to regularly refresh/update AC values in OH2 because AC parameters can be changed from phone APP(s) or even the AC remote. (There is no working OH1/OH2 binding for my AC)
Cheers
@Jannis501 i would also do it like this. But did not test it for validity.
But i think the command will automatically send 3 times by the routine. So you should think about better placement or antenna setup.
Maybe you need an additional sleep after the wait for the transceiver to be available again.
Looks interesting, but I already done the http part in my bash scripts.
I feel that the polling bit is the only thing lacking from the exec2 binding, but it can perhaps be achieved with the use of a timer and a post-update into the virtual switch.
Then you have multiple options.
But i still think your solution has more overhead then doing it with the http binding.
so after reading and going through a lot of sites and this page here I was not really able to get it happening but I think I’m close to to where I wanted to be but please I need some more help, I would like if someone can point me to the right path for setting up my 433MHZ door sensor. I have installed 433UTILS into my Pi since I find it easier to deal with, please tell me where I went wrong, here is what my items, rules and things look like :
RULES : rule "DOORSENSOR"
when
Item DOORSENSOR chaned to OPEN
then
postUpdate (433Utils/RPi_utils.state == OPEN){
}
if(receivedCommand == 14756833){ postUpdate DOORSENSOR.statusCommand =(“OPEN”) }else{ if DOORSENSOR.stateCommand =(“CLOSE”) postUpdate (433Utils/RPi_utils.state == CLOSE) }
end
ITEMS : Switch DOORSENSOR { channel=“exec:command:./RFSniffer:run” }
String DOORSENSOR { channel=“exec:command:./RFSinffer:input” }
THINGS :Thing exec:command:./RFSniffer [
command="/home/pi/433Utils/RPi_utils/./RFSniffer 14756833",
interval=2,
autorun=true]
I need statues for OPEN/CLOSE for door sensor to appear on habpanel. Using Raspberry Pi 3 with OH2
@ramy_rutu please use code fences to make you code readable.
Use the buttons at the top row of the text box. Or use the trippel quotation mark.
```
your code goes here
```
Please edit you previous post, thank you.
First I dont think using “.” and “/” in the thing name is a good idea.
Second you have two items called DOORSENSOR one Switch and one String, how schould openhab know which you want to control?
Third typos “chaned” is not “changed”
I will add some comment to your code:
.things
THINGS :Thing exec:command:./RFSniffer [ /* dot and slash are pretty bad in names */
command="/home/pi/433Utils/RPi_utils/./RFSniffer 14756833", /* does RFSniffer work like this ?*/
interval=2,
autorun=true]
/* as the sniffer usually sniff continously the first execution will never stop, untill someone stops it*/
.items
/* two items with the same name, this won´t work */
Switch DOORSENSOR { channel=“exec:command:./RFSniffer:run” } /* with this switch connected to the Thing run channel you can start the execution when toggleing to on */
String DOORSENSOR { channel=“exec:command:./RFSinffer:input” } /* this is the channel where you can input some data to the thing, not what the thing will answer back to you */
/* no output channel so if the command line gets executed we will never know what the result was.*/
.rules
rule "DOORSENSOR"
when Item DOORSENSOR chaned /*changed*/ to OPEN
then
postUpdate (433Utils/RPi_utils.state == OPEN){}
/*? Where is this item defined? And "/" in a name is a no go.*/
/* this is a mix if a postUpdate and if clause ? */
if(receivedCommand == 14756833){ /* probably should be compared with a string "14756833" if i asume DOORSENSOR is the string item. */
postUpdate DOORSENSOR.statusCommand =(“OPEN”)
/* postUpdate(DOORSENSOR, OPEN) DOORSENSOR.postUpdate(OPEN) or When i asume DOORSENSO is the switch but who knows */
}else{
if DOORSENSOR.stateCommand =(“CLOSE”)
postUpdate (433Utils/RPi_utils.state == CLOSE)
}
/* else if (DOORSENSOR.state == CLOSED){ postUpdate(DOORSENSOR, CLOSE ) } , and here is the best thing posting to the same item the allready known state. You have to give each item an unique name.*/
end
Please start over again, read carefully try some simple things for which you find Tutorials and first try to reproduce them and understand how everything works. Don´t rush fast. For Openhab there is a lot which has to be learned.
But, to answer your question:“This does not work at all”.
If RFSniffer would only listen to the given code and returns the recieved command, it wont stop.
So starting a RFSniffer every 2 second is not a good idea, besides the Reciever is allready in use by the first Sniffer.
imagine you would like to lsiten to multiple contacts, but if the one Thing you allready block the receiver.
You don’t want to regularly trigger something, you want to continously wait for an event like a received contact status.
Thus you will need to set up somthing like a MQTT server, which will wait for incomming data and forwards it to the Openhab MQTT Binding client.
And you will need a process which listens to the receiver and publish the data to the MQTT Server.
Have a look here, here and here for more info.
Or at least something like that.
rule "Wohnzimmer"
when Item Wohnzimmer changed to OPEN
then
postUpdate (Wohnzimmer.state == OPEN){}
if(receivedCommand == 14756833){
postUpdate(DOORSENSOR, OPEN)
}else{
if Wohnzimmer.stateCommand =(“FALSE”)
(Wohnzimmer_Out.state == CLOSED)
}
end
Group Licht_EG "Licht"
Switch Wohnzimmer
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" }
```php
sitemap funklicht label="Erdgeschoss" {
Frame label="Licht" {
Switch item=Wohnzimmer icon="light"
}
}
Thing exec:command:Wohnzimmer [
command="/home/pi/433Utils/RPi_utils/Wohnzimmer_decke.sh %2$s",
interval=0,
autorun=false
I have tried everything on this page and I don't know what als I should do ... I am only looking to get a states from my 433mhz door sensor to show on my openhab2 at habpanel for door open / door close. I am not expert for using python and Linux but I'm trying my best . if anyone here will post the right scripts for this project I would really appreciate it. I know most of the scripts in this page is for sending code but for my project its receiving code to give a status for open or close
@Josar you were absolutely right!
I ended up using the http binding with cache.
One GET returns multiple parameters.
Here are my items for picking out single values from the cache string:
ret=OK,pow=1,mode=4,adv=,stemp=24.0,shum=0,dt1=25.0,dt2=M,dt3=25.0,dt4=24.0,dt5=24.0,dt7=25.0,dh1=AUTO,dh2=50,dh3=0,dh4=0,dh5=0,dh7=AUTO,dhh=50,b_mode=4,b_stemp=24.0,b_shum=0,alert=255,f_rate=A,f_dir=0,b_f_rate=A,b_f_dir=0,dfr1=5,dfr2=5,dfr3=5,dfr4=A,dfr5=A,dfr6=5,dfr7=5,dfrh=5,dfd1=0,dfd2=0,dfd3=0,dfd4=0,dfd5=0,dfd6=0,dfd7=0,dfdh=0
http.cfg:
# configuration of the first cache item
ACcache.url=http://192.168.1.8/aircon/get_control_info?
ACcache.updateInterval=10000
# configuration of the second cache item
ACsensorCache.url=http://192.168.1.8/aircon/get_sensor_info?
ACsensorCache.updateInterval=60000
.items
// http items
String ACpowerState {http="<[ACcache:6000:REGEX(.*?pow=.*?([0-9]*).*)]"}
String ACsetTemp {http="<[ACcache:1000:REGEX(.*?stemp=.*?([0-9\\.0-9]*).*)]"}
String ACmode {http="<[ACcache:1000:REGEX(.*?mode=.*?([0-9]*).*)]"}
String ACfanRate {http="<[ACcache:1000:REGEX(.*?f_rate=.*?([AB34567]*).*)]"}
String ACfanDir {http="<[ACcache:1000:REGEX(.*?f_dir=.*?([0-9\\.0-9]*).*)]"}
String ACinDoorTemp "Inside temperature [%s °C]" <temperature> {http="<[ACsensorCache:1000:REGEX(.*?htemp=.*?([0-9\\.0-9]*).*)]"}
String ACoutDoorTemp "Outside temperature [%s °C]" <temperature> {http="<[ACsensorCache:1000:REGEX(.*?otemp=.*?([0-9\\.0-9]*).*)]"}