· 6 years ago · Oct 04, 2019, 06:52 AM
1 AQI Alert-V2-API-TSK (657)
2 A1: [X] Goto [ Type:Action Label Number:1 Label:NEW BY API ]
3 <Test Network Connectivity>
4 A2: Anchor
5 A3: Run Shell [ Command:ping -c 1 8.8.8.8 Timeout (Seconds):10 Use Root:On Store Output In:%Ping Store Errors In:%PingErr Store Result In: Continue Task After Error:On ]
6 A4: If [ %PingErr Set ]
7 A5: [X] Flash [ Text:Stop@! Long:Off ]
8 A6: Stop [ With Error:Off Task: ]
9 A7: End If
10 <NEW BY API>
11 A8: Anchor
12 <Set AirVisual API>
13 A9: Variable Set [ Name:%AIRVISUALAPIKEY To:YOURAPIKEY Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ] If [ %AIRVISUALAPIKEY !Set ]
14 A10: Get Location [ Source:Net Timeout (Seconds):100 Continue Task Immediately:Off Keep Tracking:Off ]
15 A11: Variable Set [ Name:%locationfromnetwork To:%LOCN Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
16 A12: Variable Split [ Name:%locationfromnetwork Splitter:, Delete Base:Off ]
17 A13: HTTP Request [ Method:GET URL:https://api.airvisual.com/v2/nearest_city?lat=%locationfromnetwork1&lon=%locationfromnetwork2&key=%AIRVISUALAPIKEY Headers: Query Parameters: Body: File To Send: File To Save With Output: Timeout (Seconds):30 Trust Any Certificate:Off ]
18 A14: [X] Set Clipboard [ Text:%http_data Add:Off ]
19 A15: AutoTools Json Read [ Configuration:Input Format: Json
20 Json: %http_data
21 Fields: data.city,data.state,data.current.pollution.aqius
22 Separator: , Timeout (Seconds):60 ]
23 A16: [X] Set Clipboard [ Text:%data_city
24 %data_state
25 %data_current_pollution_aqius Add:Off ]
26 A17: If [ %data_current_pollution_aqius Set ]
27 <Good>
28 A18: If [ %data_current_pollution_aqius < 51 ]
29 A19: Variable Set [ Name:%aqiinfo To:Good Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
30 <Good>
31 A20: Variable Set [ Name:%fontcolor To:#009865 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
32 <Good>
33 A21: Variable Set [ Name:%aqicon To:ic_face_green_light Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
34 <Moderate>
35 A22: Else If [ %data_current_pollution_aqius > 50 & %data_current_pollution_aqius < 101 ]
36 A23: Variable Set [ Name:%aqiinfo To:Moderate Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
37 <Moderate>
38 A24: Variable Set [ Name:%fontcolor To:#FEDE33 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
39 <Moderate>
40 A25: Variable Set [ Name:%aqicon To:ic_face_yellow_light Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
41 <Unhealthy for Sensitive Groups>
42 A26: Else If [ %data_current_pollution_aqius > 100 & %data_current_pollution_aqius < 151 ]
43 A27: Variable Set [ Name:%aqiinfo To:Unhealthy for Sensitive Groups Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
44 <Unhealthy for Sensitive Groups>
45 A28: Variable Set [ Name:%fontcolor To:#FF9934 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
46 <Unhealthy for Sensitive Groups>
47 A29: Variable Set [ Name:%aqicon To:ic_face_orange_light Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
48 <Unhealthy>
49 A30: Else If [ %data_current_pollution_aqius > 150 & %data_current_pollution_aqius < 201 ]
50 A31: Variable Set [ Name:%aqiinfo To:Unhealthy Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
51 <Unhealthy>
52 A32: Variable Set [ Name:%fontcolor To:#CC0033 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
53 <Unhealthy>
54 A33: Variable Set [ Name:%aqicon To:ic_face_red_light Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
55 <Very Unhealthy>
56 A34: Else If [ %data_current_pollution_aqius > 200 & %data_current_pollution_aqius < 301 ]
57 A35: Variable Set [ Name:%aqiinfo To:Very Unhealthy Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
58 <Very Unhealthy>
59 A36: Variable Set [ Name:%fontcolor To:#670099 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
60 <Very Unhealthy>
61 A37: Variable Set [ Name:%aqicon To:ic_face_purple_light Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
62 <Hazardous>
63 A38: Else If [ %data_current_pollution_aqius > 300 ]
64 A39: Variable Set [ Name:%aqiinfo To:Hazardous Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
65 <Hazardous>
66 A40: Variable Set [ Name:%fontcolor To:#7E0123 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
67 <Hazardous>
68 A41: Variable Set [ Name:%aqicon To:ic_face_maroon_light Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
69 A42: End If
70 A43: AutoNotification [ Configuration:Title: AQI Alert!
71 Text: Latest update %TIME.<br>
72 Current AQI in %data_city, %data_state is.<br>
73 <font color="%fontcolor">%data_current_pollution_aqius --- %aqiinfo</font>.
74 Action on Touch: antile=:=aqialert
75 Icon: /storage/emulated/0/Tasker/.icn/%aqicon.png
76 Status Bar Icon Manual: /storage/emulated/0/Tasker/.icn/%aqicon.png
77 Status Bar Text Size: 16
78 Id: airpollutionalert
79 Priority: 0
80 Group Key: aqilalertkey
81 Separator: , Timeout (Seconds):20 ]
82 <check if connect to headphone>
83 A44: If [ %BluetoothConnected ~ yes & %BluetoothConnectedDeviceName !~ Mi Smart Band 4 | %HeadphonePlugged ~ yes ]
84 A45: Say [ Text:Current AQI in %data_city, %data_state is
85 %data_current_pollution_aqius --- %aqiinfo Engine:Voice:%TTS_English Stream:3 Pitch:5 Speed:5 Respect Audio Focus:On Network:Off Continue Task Immediately:Off ]
86 A46: End If