I wanted Tasker to access info given by KWGT in order to -for instance- say out loud the remaining time of currently playing track $tf(mi(pos),mm:ss)$
Since KWGT doesn't support this right now, I managed a tricky way to do it as follows:
- Generate a global var: currentTrackPos with value $tf(mi(pos),mm:ss)$
- Add Text Komponent to the widget with this formula: $sh("echo '" + gv(currentTrackPos, "No data") + "' > '/sdcard/myfile.txt'")$
- Now from Tasker you'll be able to read the text file and get the data.
Then I was trying to improve this solution in order to avoid unnecessary text file rewrites, so I added a KWGT Send Variable action to Tasker with var getTrackPos that gets values 1 or 0 wheter I want it to be updated or not. Tried this formula:
$if(br(tasker, getTrackPos), sh("echo '" + gv(currentTrackPos, "No data") + "' > '/sdcard/myfile.txt'"), "No updates")$
but something is not working as expected. When getTrackPos equals 0, KWGT keeps executing the shell script that writes the info in the text file. Is it a bug or else what am I doing wrong?
Thank you in advance.
This is not a bug, unfortunately Kustom parses arguments before function so regardless of what you write in the IF the statement with the shell command will always be executed, there is no way of doing this yet, i will probably add actions to send data back to Tasker at some point or to read Kustom globals from Tasker directly
Solved you must create a false variable
for the function Sh ex. Vsh (name 1st Global variable)
$if(gv(timeTP2)=1,echo '+gv(Vtemp)+' >'/sdcard/Kustom/database/dbtemp_0.txt',"")$
Where "gv (timeTP2)" will be a timer:
$if((gv(vtemp)<gv(vtemp2))&(gv(vtemp)!=gv(vtemp2) ),(if(gv(v100)<=0, tu(seq,.5, gv(v100) = (gv(v100) +2),1),else, "0")),else,"3" )$
It will only be necessary to include in the conditional "IF", the variable gv (vsh) in the content of the function Sh.
With this option you can connect to .txt files, as a database without the need for Tasker.
#Example to detect annual min and max of temperature. Need to create folders and .txt files in /sdcard/Kustom/database/dbtemp_0.txt and others files.