This page last changed on Jul 02, 2014 by sirvsz28.
I am having a huge issue trying to get open remote sensors to work with the regex and shell scripts.
Essentially, I created an object to run the script and used regex to filter out the response.
Running the shell logs, I see that I am actually getting the correct response. I am getting no regex errors so I assume it is finding what it needs.
I checked with an online regex tester, and it seems to test out fine with the output and input i provide.
The issue, when I apply the regex to a custom sensor, the label for that sensor always shows N/A.
Could someone simply show me an example of their setup (or sample setup)?
Looking for the following:
Sample shell script
Screen shots of Open remote setup. Command, regex, sensor, label, etc.
I hope its not too much to ask, I'm just at a complete loss.
I figure its easier to ask for a working example and figure out what mine is missing than uploading my stuff and asking for help troubleshooting.
Thank you for any and all help!
Google is your best friend. I tried how to shell script, and got this a.o.:
Posted by pz1 at Jul 02, 2014 16:50
Thank you for the reply.
I've been through this piece, and configured my sensors to be very similar.
The issue I think I may be having could be related to my script itself and how/what it is returning.
The reason I ask screen shots and all is to make sure I'm not doing anything stupid, but currently my system is setup the same as the link you have provided.
The test still shows as n/a though.
Posted by sirvsz28 at Jul 02, 2014 21:52
There is a little problem with the Execute Shell protocol which makes it not working after updating the design. The working work around is to hard stop and start the controller (it can be achieved by rebooting the computer which is running the controller).
Posted by aktur at Jul 07, 2014 14:56
Thanks for the suggestion Michal. I tried rebooting after I update the design, but it does not seem to be still updating, or I really have something wrong.
Here is the output from my shell.log:
DEBUG 2014-07-10 02:16:01,454 (Shell): Building ShellExe command
DEBUG 2014-07-10 02:16:01,457 (Shell): ShellExe Command: regex = (on|off)
DEBUG 2014-07-10 02:16:01,463 (Shell): ShellExe Command: sensorNamesList = test_switch
DEBUG 2014-07-10 02:16:01,470 (Shell): ShellExe Command: commandPath= /home/pi/RF24/librf24-rpi/librf24/examples/status.sh
DEBUG 2014-07-10 02:16:01,472 (Shell): ShellExe Command created successfully
DEBUG 2014-07-10 02:16:01,474 (Shell): Will start shell command: /home/pi/RF24/librf24-rpi/librf24/examples/status.sh and use params: null
DEBUG 2014-07-10 02:16:01,496 (Shell): Shell command: /home/pi/RF24/librf24-rpi/librf24/examples/status.sh returned: Hello World on 5
As I can see, the regex is looking for on or off and "on" is being returned in the string.
I tied the switch on or off to a label to say on or off, but it is always stating "N/A". Am i missing something?
Posted by sirvsz28 at Jul 10, 2014 03:31
I assume you did use a sensor of type:switch. I do a similar thing with http protocol, but I do not use () in the RegEx, just on|off.
Posted by pz1 at Jul 10, 2014 08:22
You would need a polling interval of some value to run the shell command in a loop and update sensor state. Try few seconds, for example 3s.
In the log you should see that polling.
Posted by aktur at Jul 10, 2014 14:41
Thank you for the replies Pieter and Michal.
Yes this is a switch type command. I tried to remove the (), but that does not seem to update the label.
I had also introduced the pollingInterval, but for some reason it does not seem to actually trigger off periodically.
EBUG 2014-07-11 00:53:27,187 (Shell): Found cached ShellExe command with id: 130
DEBUG 2014-07-11 00:53:27,221 (Shell): Will start shell command: /home/pi/RF24/librf24-rpi/librf24/examples/status.sh and use params: null
DEBUG 2014-07-11 00:53:27,248 (Shell): Shell command: /home/pi/RF24/librf24-rpi/librf24/examples/status.sh returned: Hello World on 5
DEBUG 2014-07-11 00:53:32,679 (Shell): Building ShellExe command
DEBUG 2014-07-11 00:53:32,682 (Shell): ShellExe Command: regex = on|off
DEBUG 2014-07-11 00:53:32,684 (Shell): ShellExe Command: pollingInterval = 2
DEBUG 2014-07-11 00:53:32,687 (Shell): ShellExe Command: sensorNamesList = test_switch
DEBUG 2014-07-11 00:53:32,689 (Shell): ShellExe Command: commandPath= /home/pi/RF24/librf24-rpi/librf24/examples/status.sh
DEBUG 2014-07-11 00:53:32,691 (Shell): ShellExe Command created successfully
DEBUG 2014-07-11 00:53:32,694 (Shell): Will start shell command: /home/pi/RF24/librf24-rpi/librf24/examples/status.sh and use params: null
DEBUG 2014-07-11 00:53:32,714 (Shell): Shell command: /home/pi/RF24/librf24-rpi/librf24/examples/status.sh returned: Hello World on 5
I'm starting to think OpenRemote really hates raspberry Pis or me
Posted by sirvsz28 at Jul 11, 2014 02:06
From the log I see that you did not reboot the controller after updating it as it is using Found cached ShellExe command. You really need do this if you change anything in the command.
Your polling interval is 2 which means probably 2ms, this is too frequently, try to put few seconds there, either 2000 or 2s would do.
Without () your regex would not return the value which switch sensor can use. However, if you use a custom sensor instead then it can accept any return value and you will see in the linked label what was given back.
Posted by aktur at Jul 11, 2014 11:15
Without () your regex would not return the value which switch sensor can use
Apparantly the ShellExe command works differently compared to http command. For my http calls to RaZberry I had to remove the () to get it working at the time.
Posted by pz1 at Jul 11, 2014 12:36