I'm creating a task where the weather is pulled by an http request this is what I've got so far:
<TaskerData sr="" dvi="1" tv="5.10.1">
<Task sr="task79">
<cdate>1494395940378</cdate>
<edate>1604394719692</edate>
<id>79</id>
<nme>Create Weather Alert</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%json</Str>
<Str sr="arg1" ve="3"> </Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
<Int sr="arg5" val="3"/>
</Action>
<Action sr="act1" ve="7">
<code>339</code>
<Bundle sr="arg0">
<Vals sr="val">
<net.dinglisch.android.tasker.RELEVANT_VARIABLES><StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%http_file_output
File Output
Will always contain the file's full path even if you specified a directory as the File to save.</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1>%http_response_code
Response Code
The HTTP Code the server responded</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2>%http_cookies
Cookies
The cookies the server sent in the response in the Cookie:COOKIE_VALUE format. You can use this directly in the 'Headers' field of the HTTP Request action</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES3>%http_headers()
Response Headers
The HTTP Headers the server sent in the response. Each header is in the 'key:value' format</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES3><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES4>%http_response_length
Response Length
The size of the response in bytes</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES4></StringArray></net.dinglisch.android.tasker.RELEVANT_VARIABLES>
<net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>[Ljava.lang.String;</net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>
</Vals>
</Bundle>
<Int sr="arg1" val="0"/>
<Int sr="arg10" val="0"/>
<Int sr="arg11" val="0"/>
<Str sr="arg2" ve="3">http://api.openweathermap.org/data/2.5/forecast?lat=54.5234936&lon=-1.3049079&appid=<----APIKEY---->&units=metric&cnt=5</Str>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3">Download/weather.json</Str>
<Int sr="arg8" val="30"/>
<Int sr="arg9" val="0"/>
</Action>
<Action sr="act2" ve="7">
<code>417</code>
<Str sr="arg0" ve="3">Download/weather.json</Str>
<Str sr="arg1" ve="3">%json</Str>
</Action>
<Action sr="act3" ve="7">
<code>548</code>
<Str sr="arg0" ve="3">%json</Str>
<Int sr="arg1" val="1"/>
</Action>
<Action sr="act4" ve="7">
<code>129</code>
<Str sr="arg0" ve="3">var parsedjson=JSON.parse(global('json'));
setLocal('test',parsedjson.cod);
flashLong(local('test'));</Str>
<Str sr="arg1" ve="3"/>
<Int sr="arg2" val="1"/>
<Int sr="arg3" val="45"/>
</Action>
<Action sr="act5" ve="7">
<code>548</code>
<on>false</on>
<Str sr="arg0" ve="3">%parsedjson</Str>
<Int sr="arg1" val="1"/>
</Action>
<Action sr="act6" ve="7">
<code>129</code>
<on>false</on>
<Str sr="arg0" ve="3">var test="test";</Str>
<Str sr="arg1" ve="3"/>
<Int sr="arg2" val="1"/>
<Int sr="arg3" val="45"/>
</Action>
<Action sr="act7" ve="7">
<code>548</code>
<Str sr="arg0" ve="3">%test</Str>
<Int sr="arg1" val="1"/>
</Action>
<Img sr="icn" ve="2">
<nme>hl_aaa_ext_sun</nme>
</Img>
</Task>
</TaskerData>
The %json variable get filled with this:
{
"cod": "200",
"message": 0,
"cnt": 1,
"list": [
{
"dt": 1604394000,
"main": {
"temp": 5.69,
"feels_like": 1.68,
"temp_min": 5.69,
"temp_max": 5.99,
"pressure": 1011,
"sea_level": 1011,
"grnd_level": 1008,
"humidity": 81,
"temp_kf": -0.3
},
"weather": [
{
"id": 802,
"main": "Clouds",
"description": "scattered clouds",
"icon": "03d"
}
],
"clouds": {
"all": 49
},
"wind": {
"speed": 3.5,
"deg": 196
},
"visibility": 10000,
"pop": 0,
"sys": {
"pod": "d"
},
"dt_txt": "2020-11-03 09:00:00"
}
],
"city": {
"id": 2636005,
"name": "Thornaby",
"coord": {
"lat": 54.52,
"lon": -1.3
},
"country": "GB",
"population": 22356,
"timezone": 0,
"sunrise": 1604387520,
"sunset": 1604420727
}
}
What I would like to be able to do is getting simple values from the json. I tried doing that here
var parsedjson=JSON.parse(global('json'));
setLocal('test',parsedjson.cod);
flashLong(local('test'));
Not only isn't flashLong doing anything, when the last step of the task (flash) runs I only see "%test".
Also, to make sure, let's say I want to get "temp" from the json the regular syntax applies right?
parsedjson.list[0].main.temp
Can anyone help me understand why %test isn't being filled like I want it?
DISCLAIMER: I know about autotools. But I'd prefer to do it this way as I don't use autotools for anything else.