$mi(state)$ to .txt with shell echo

Kindly ask for help how to get the latest and current mi(state) to a text file.

I can't bring it to work with an if-condition:

$if(gv(Spotify)=PLAYING,

sh("echo 'PLAYING' > '/sdcard/Kustom/Spotify.txt'"),

sh("echo 'PAUSED' > '/sdcard/Kustom/Spotify.txt'")$

even without work is:

$if(gv(Spotify)=PLAYING,

sh(gv(SpotSH)),sh(gv(SpotSH)))$

My global variables are:

  • gv(Spotify): $mi(state)$
  • gv(SpotSH): $if(mi(state)=PLAYING,
  • gv(spotPlay),gv(spotPaus))$
  • gv(spotPlay): echo 'PLAYING' > '/sdcard/Spotify.txt'
  • gv(spotPaus): echo 'PAUSED' > '/sdcard/Spotify.txt

Perhaps anyone could help.

Best regards, Daniel

Hi did you ever figure this out?

I did, but I don't know remember how. It didn't work very reliable. I thought it would work better to react with tasker to a changed file than to another system change.

Nowadays tasker reacts so good, I don't need the with-the-file-workaround.