🌱 Shortcut scripting
Journal and weather
TL;DR forcastio.io is going away in a year
API options http://www.ncei.noaa.gov/support/access-data-service-api-user-documentation
https://weather-gov.github.io/api/gridpoints https://api.weather.gov/gridpoints/LMK/51,88/forecast
https://www.weather.gov/documentation/services-web-api https://openweathermap.org/price
Possible history api http://www.ncei.noaa.gov/support/access-data-service-api-user-documentation
Current Weather Forecast.io https://www.icloud.com/shortcuts/f49b7dd03987459a93da2e0abb02ffdc
Start Journal Forecast.io https://www.icloud.com/shortcuts/35adfc074ea146fa8657896303eccb6a
Image Journal Forecast.io https://www.icloud.com/shortcuts/c83feb2619374fe9866e6794fe335649
Start Jounal Script Weather.gov https://www.icloud.com/shortcuts/063ceaf3903e4ee9b8e029113fedf5cb
New Journal
{
"always_run_in_app" : false,
"icon" : {
"color" : "red",
"glyph" : "file-medical"
},
"name" : "Journal",
"script" : "\/\/ get date\nconst now = new Date()\n\n\/\/ get location \nconst {longitude, latitude} = await Location.current()\nconst geoCode = await Location.reverseGeocode(latitude, longitude)\nconst zip = geoCode[0].postalAddress.postalCode\nconst tagLocation = #journal\/location\/${zip}\n\n\/\/ get weather\nconst req = new Request(https:\/\/api.weather.gov\/points\/${latitude},${longitude})\nreq.headers = {\n\t\"User-Agent\": \"Journal <brandonstephens@me.com>\", \n\t\"Accept\": \"application\/ld+json\"\n}\n\nconst weather = await req.loadJSON()\n\/\/ console.log(weather.forecastHourly)\nconst forecastReq = new Request(weather.forecastHourly)\nforecastReq.headers = {\n\t\"User-Agent\": \"Journal <brandonstephens@me.com>\", \n\t\"Accept\": \"application\/ld+json\"\n}\nconst hourly = await forecastReq.loadJSON()\nconst {temperature, shortForecast} = hourly.periods[0]\n\n\/\/ prep content\nconst titleDate = new DateFormatter()\ntitleDate.dateFormat = \"yyyy-MM-dd\"\nconst title = # Journal-${titleDate.string(now)}\n\nconst fullDate = new DateFormatter()\nfullDate.useFullDateStyle()\nfullDate.useFullTimeStyle()\n\nconst bearDate = new DateFormatter()\nbearDate.dateFormat = \"yyyy\/MM\/dd\"\nconst tagDate = #journal\/date\/${bearDate.string(now)}\n\n\/\/ create bear note\nconst note = ${title}\n\n${tagDate}\n${tagLocation}\n\nDate: ${fullDate.string(now)}\nLocation: ${latitude}, ${longitude}\nWeather: ${temperature}F ${shortForecast} \n\n\n\n\/\/ console.log(note)\n\nScript.setShortcutOutput(note)\nScript.complete()\n\/\/ const baseURL = \"bear:\/\/x-callback-url\/create\"\n\/\/ let cb = new CallbackURL(baseURL)\n\/\/ cb.addParameter(\"text\", note)\n\/\/ await cb.open()",
"share_sheet_inputs" : [
]
}