Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- httpdata = JSON.parse(global('HTTPD')); // Read in data from HTTP-get
- // Set up arrays to identify months and days
- var month = new Array();
- month[0] = "January";
- month[1] = "February";
- month[2] = "March";
- month[3] = "April";
- month[4] = "May";
- month[5] = "June";
- month[6] = "July";
- month[7] = "August";
- month[8] = "September";
- month[9] = "October";
- month[10] = "November";
- month[11] = "December";
- var weekday = new Array(7);
- weekday[0] = "Sunday";
- weekday[1] = "Monday";
- weekday[2] = "Tuesday";
- weekday[3] = "Wednesday";
- weekday[4] = "Thursday";
- weekday[5] = "Friday";
- weekday[6] = "Saturday";
- // Extract time of api request from UNIX time
- time = new Date(httpdata.currently.time * 1000);
- day = weekday[time.getDay()];
- months = month[time.getMonth()];
- date = time.getDate();
- if (time.getMinutes() < 10) {
- clock = time.getHours() + ":0" + time.getMinutes();
- } else {
- clock = time.getHours() + ":" + time.getMinutes();
- }
- // Extract weather data
- temp = httpdata.currently.apparentTemperature; // Current temperature
- condition = httpdata.currently.summary; // Current weather condition summarized
- rain = httpdata.minutely.data[50].precipProbability * 100; // Probability of rain 50 minutes from now
- if (isNaN(rain)) {
- rain = 0;
- }
- forecast = httpdata.hourly.summary; // Summary for the next 36 hours
- maxTemp = httpdata.daily.data[0].temperatureMax; // Max temperature for the day
- // Extract time for sunset
- time = new Date(httpdata.daily.data[0].sunsetTime * 1000);
- if (time.getMinutes() < 10) {
- sunset = time.getHours() + ":0" + time.getMinutes();
- } else {
- sunset = time.getHours() + ":" + time.getMinutes();
- }
- // Setup string for text to speech
- string = "Good morning. The time is " + clock + " on " + day + " " + months + " " + date + ". The current temperature is " + temp + " degrees Celsius and it is currently " + condition + " outside. There is a " + rain + " percent chance that it will rain in the next hour. The forecast for the day is " + forecast + ", with a maximum temperature of " + maxTemp + " degrees Celsius. Sunset is at " + sunset + " today.";
- //flashLong(string);
- setGlobal('READOUT', string); // Write string to Tasker variable
- exit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement