I just tried with a timeout of 5000 and still not working
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
20
Arrr I see.
So I’ve just tried something super simple like this.
Try this bash script to echo a variable and append a text file, saved as /opt/echoTest.sh
echo Value received from command line is $1 \\n
new=`expr $1 \* 66`
echo After some maths it becomes $new \\n
echo $1 $new >> /opt/test.txt
exit 0
The command line of
sh /opt/echoTest.sh 2
Puts 2 132 into test.txt
@silv
So if you put this into your rule… What happens?
var myResults = executeCommandLine("sh /opt/echoTest.sh " + value.toString, 5000)
logInfo("test", "My exec results " + myResults)
A bash script to play with
#!/bin/bash
echo Value received from command line is $1 \\n
date > /opt/test.txt
echo inital value is $1 >> /opt/test.txt
new=`expr $1 \* $1`
echo $1 multipled by $1 is $new >> /opt/test.txt
echo $1 multipled by $1 is $new
exit 0
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
21
Dare I suggest that there may be an issue with the Python script ?
How have you got it working in the past / while you created it?
I thought so too but it just a empty file.py, so I don’t see where could be the problem with the python script
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
24
Best suggestion of the morning
1 Like
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
25
Soooooo
Are you actually saying that you need to write the value into this empty file, so that something else, sometime later can read this file and take the contents? (Which begs the question, “why the Something can’t just use a curl command to get the openHAB2 Item state directly”, using the REST API…
For example
curl -X GET --header "Accept: text/plain" "http://192.168.1.50:8080/rest/items/VMB7IN_0A_Counter_1/state"
This command is automatically generated and displayed in the REST API docs interface http://192.168.1.50:8080/doc/index.html#!/items/getPlainItemState
)
If so…
Take another slurp from the coffee and read the last few posts… Slowly…
2 Likes
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
26
I’ve just thought of something even easier to put into a rule to echo a value into a text file, but I’m not simply going to type it here (straight away), I think it would be a much better learning experience if you attempted it yourself.
(Although, obviously we’ll all carry on helping, it’s just we like teach, rather than “do for you” )
Careful when trying to redirect or pipe in executeCommandLine it does not run in a shell and so shell features will not work.
It’s not the same as the console and is not supposed to be.
why not letting the slider trigger a script that gets the value from the REST API as @MDAR suggested. I think that is much easier than worrying about how to get the value into the extnernal file resp. use it as a parameter.
As far as I understand you need to use the slider as a trigger anyway and you need to use a script anyway.