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?
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
Best suggestion of the morning
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ā¦
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ā )
Soooā¦ I tried to echo the variable but I am stuckā¦ I used
sudo sh -c 'echo "whatever I want" >>/file.txt'
and
echo 'whatever I want' | sudo tee -a /etc/ReadValue.py
which worked on the terminal of course but the typo doesnāt match with the executeCommandLine. If you cand advise me about your thought
** I have to use the sudo in order to have the permission, hence the tee -a **
@MDAR I need the permissionā¦ hence sudo tee
PS : I am a new user so Iāve reached the maximum comments/day, I only can edit
I can see that it wonāt workā¦
just try
echo whatever I want >> file.txt
or start simply
echo TEST >> file.txt
or if you donāt want to append the file.txt, just try
echo TEST > file.txt
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.
I finally decided to use curl command in order to have item state directly, and it works fine. So thanks for your help from the beginning !
Before I end this topic, what was your idea, out of curiosity ?
As long as itās working for you.
As others have said, there are other ways.
My āideaā was a simply comand like this in the rule
executeCommandLine("/bin/echo " + value.toString +" > /etc/ReadValue.py", 5000)
It might work, it might notā¦