@SnitzelWeck92 I’m trying to replicate your setup but having issues with one error in my openhab.log. Did you come across this issue during your setup? The exec command and accompanying script which turns the light on and off fails to execute.
2017-03-30 23:30:06.166 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate command 'ON' for item 'PowerSwitch1Switch' to handler for channel 'exec:command:PowerSwitch1Switch-control:input', because no thing with the UID 'exec:command:PowerSwitch1Switch-control' could be found.
Hy. I hope I find help here. I’ve been trying to use a 433 mhz module for a long time with openhab.
I can use it in the shell with the following command: /home/openhabian/433Utils/RPi_utils/./codesend 13108705.
And now I try desperately to integrate this command with exec binding (version 2). I hope who can help, I try to send the command as a push button.
Where is my mistake? Post my composition. Thank you
#!/bin/sh
if [ "$1" = "off" ] || [ "$1" = "0" ] || [ "$1" = "OFF" ]; then
/home/openhabian/433Utils/RPi_utils/./codesend 13108705
else
/home/openhabian/433Utils/RPi_utils/./codesend 13108705
fi
rule
rule "Poweroutlet B"
when
Item Wohnzimmer_Decke received command
then
if(receivedCommand == ON){
Wohnzimmer_Decke.sendCommand("13108705")
}else{
Remote_Send_Args.sendCommand("10010 2 0")
}
// wait for the command to complete, state will be NULL if not used befor$
while(Remote_Send.state != OFF){
Thread::sleep(500)
}
logInfo("Power_Plug", "Resuts are: \n" + Remote_Send_Out.state )
end
I get this error from the log-file:
[hab.binding.exec.handler.ExecHandler] - An exception occurred while formatting the command line with the current time and input values : ‘Format specifier ‘%2$s’’
Have a look here for a detailed setup with the exec binding
I don’t know if it is possible to directly set on/off from the mapping to the format specifier. Maybe there is no way around a rule.
But I had read that this error only occurs once when the item is not defined, after first execute it should be gone. If not try the setup like in the Tutorial.
Thank you Josar. That helped a lot. No more error messages in the log file.
But still, it doesn‘t work.
I can change the switch and the command „ON“ (or „OFF“) is given. See Log file.
But it feels like EXEC does not execute anything…
Logfile now is:
Item 'PAR1500_A1' received command ON
PAR1500_A1 changed from NULL to ON
This should produce an output in the log when the rule is fired.I cannot see this in the log you posted.
So either the rule is not fired, rebooting Pi could help. Or you did not post the line.
Are you able to execute the command as user openhabian in the command line?
sudo -u openhabian /usr/bin/python /etc/openhab2/senditgw433.py A 1 on
are you able to execute the rule? Is your rule file called .rules ? This is randome guessing why your rule is not fireing. try some simple rule.
rule "itgw"
when
Item PAR1500_A1 received command ON
then
// Set button back to see if rule fires
PAR1500_A1.postUpdate(OFF)
end
To answer your first question: Yes, I can execute with the user „openhabian“.
Question 2: Yes, my rules have the ending .rules
Your simplified rule worked well. So far so good.
But I also had some trouble with this:
[hab.binding.exec.handler.ExecHandler] - Couldn’t transform response because transformationService of type ‘REGEX’ is unavailable
This was solved somewhere else and I managed to fix it.
I forgot to install the EXEC transformation service. Well…
Now your script works.
But I found out that I can‘t just copy & paste this code. It just doesn‘t work to use multiple “when“ commands in one .rules file. At least I don’t know the syntax to do it right.
So I split it into three .rules files and now I can switch all three powerplugs on and off.
Very well. It might me not the most smart solution to use three .rules files but it works.
Thank you again to help me climb over these last borders…
is there a way to detect an item is on/off using PING but using the exec binding ? The state of this item will be used in another rule
as the network binding is not capable of doing what I require, im thinking I can executecommandline a ping, but checking if it replies or not is what im struggling with