├── LICENSE.txt ├── README.md ├── screenshot - Buienradar.png ├── screenshot - ICY.png ├── screenshot - Trakt.tv.png └── scripts ├── Buienradar └── Buienradar.js ├── ICY - Thermostat ├── ICY - Current temperature.js ├── ICY - Set credentials.js ├── ICY - Temperature down.js └── ICY - Temperature up.js └── Trakt.tv Movie Recommendations └── Trakt.TV Recommendations.js /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2018 Wouter Janson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scriptable Collection 2 | This repo contains some of my scripts that I use with the [Scriptable](https://scriptable.app) app on my iPhone in order to extend the functionality of Siri. Scriptable is even more powerfull than Siri Shortcuts because you can leverage the power of JavaScript and create visual responses. 3 | 4 | This repo will occasionally be updated with new scripts. 5 | 6 | ## Buienradar 7 | 8 | 9 | This script simply shows the [Buienradar](https://www.buienradar.nl) widget, based on your current location, within a webview in order to retrieve it using Siri. Only usable in NL and BE. 10 | 11 | ## ICY Thermostat 12 | 13 | 14 | ### Setting up 15 | - `ICY - Set credentials.js` Used to store your credentials used by the other scripts 16 | - `ICY - Current temperature.js` Gets the current and target temperature 17 | - `ICY - Temperature down.js` Lowers the target temperature 18 | - `ICY - Temperature up.js` Raises the target temperature 19 | 20 | These scripts are pretty basic. 21 | 22 | #### ICY - Set credentials.js 23 | ```Javascript 24 | Keychain.set("ICY_Username", "MyUsername"); 25 | Keychain.set("ICY_Password", "MyPassword"); 26 | Keychain.set("ICY_Room", "my room"); // Used for Siri responses 27 | 28 | Keychain.set("ICY_API", "https://portal.icy.nl"); // URL to ICY API, already set for the (Dutch) Essent E-Thermostaat 29 | ``` 30 | 31 | ## Trakt.tv Movie Recommendations 32 | 33 | 34 | This little script uses the [Trakt.tv](https://trakt.tv) API to retrieve your movie recommendations and displays them in a UITable. The posters are provided by the API from [The Movie Database](https://www.themoviedb.org) -------------------------------------------------------------------------------- /screenshot - Buienradar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WouterJanson/Scriptable-Collection/92c5f93700d171d8d78b1aedf60e1a15479079d5/screenshot - Buienradar.png -------------------------------------------------------------------------------- /screenshot - ICY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WouterJanson/Scriptable-Collection/92c5f93700d171d8d78b1aedf60e1a15479079d5/screenshot - ICY.png -------------------------------------------------------------------------------- /screenshot - Trakt.tv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WouterJanson/Scriptable-Collection/92c5f93700d171d8d78b1aedf60e1a15479079d5/screenshot - Trakt.tv.png -------------------------------------------------------------------------------- /scripts/Buienradar/Buienradar.js: -------------------------------------------------------------------------------- 1 | // Variables used by Scriptable. 2 | // These must be at the very top of the file. Do not edit. 3 | // icon-color: blue; icon-glyph: umbrella; 4 | 5 | Location.setAccuracyToThreeKilometers() 6 | var location = await Location.current() 7 | html = ` 8 | 9 | ` 10 | WebView.loadHTML(html, null, new Size(0, 330)) -------------------------------------------------------------------------------- /scripts/ICY - Thermostat/ICY - Current temperature.js: -------------------------------------------------------------------------------- 1 | // Variables used by Scriptable. 2 | // These must be at the very top of the file. Do not edit. 3 | // icon-color: green; icon-glyph: thermometer-half; 4 | // author: Wouter Janson 5 | // website: https://wouterjanson.nl 6 | 7 | // Setup 8 | if (!Keychain.contains("ICY_Password")) { 9 | var alert = new Alert() 10 | alert.title = "ICY Thermostat" 11 | alert.message = "Please first run the 'Set credentials' script, in order to use this script" 12 | alert.present() 13 | return; 14 | } 15 | let apiUrl = Keychain.get("ICY_API") 16 | let username = Keychain.get("ICY_Username") 17 | let password = Keychain.get("ICY_Password") 18 | let room = Keychain.get("ICY_Room") 19 | 20 | // Login 21 | let loginReq = new Request(apiUrl + "/login") 22 | loginReq.method = "POST" 23 | loginReq.addParameterToMultipart("username", username) 24 | loginReq.addParameterToMultipart("password", password) 25 | let loginJson = await loginReq.loadJSON() 26 | 27 | let token = loginJson['token'] 28 | let uuid = loginJson['serialthermostat1'] 29 | 30 | // Get Temperature 31 | let tempReq = new Request(apiUrl + "/data") 32 | tempReq.method = "GET" 33 | tempReq.formData = {"username" : username, "password": password} 34 | tempReq.headers = {"Session-token" : token} 35 | let tempJson = await tempReq.loadJSON() 36 | let temperature = tempJson['temperature2'] 37 | let targetTemperature = tempJson['temperature1'] 38 | 39 | // Display 40 | let html = ` 41 | 57 | 58 |
59 |

Temperature: ${temperature}℃
Target: ${targetTemperature}℃

60 |
61 | ` 62 | 63 | if (config.runsWithSiri) { 64 | Speech.speak(`The ${room} temparature is at ${temperature}°C and the target is at ${targetTemperature}°C`) 65 | } 66 | 67 | WebView.loadHTML(html, null, new Size(0, 150)) -------------------------------------------------------------------------------- /scripts/ICY - Thermostat/ICY - Set credentials.js: -------------------------------------------------------------------------------- 1 | // Variables used by Scriptable. 2 | // These must be at the very top of the file. Do not edit. 3 | // icon-color: green; icon-glyph: cogs; 4 | // author: Wouter Janson 5 | // website: https://wouterjanson.nl 6 | 7 | // Enter your credentials and settings for use in the ICY scripts 8 | Keychain.set("ICY_Username", "MyUsername"); 9 | Keychain.set("ICY_Password", "MyPassword"); 10 | Keychain.set("ICY_Room", "my room"); // Used for Siri responses 11 | 12 | Keychain.set("ICY_API", "https://portal.icy.nl"); // URL to ICY API, already set for the (Dutch) Essent E-Thermostaat 13 | 14 | // succes alet 15 | var alert = new Alert() 16 | alert.title = "ICY Thermostat" 17 | alert.message = "All credentials are set! 🎉\nYou can now use the ICY scripts." 18 | alert.present() -------------------------------------------------------------------------------- /scripts/ICY - Thermostat/ICY - Temperature down.js: -------------------------------------------------------------------------------- 1 | // Variables used by Scriptable. 2 | // These must be at the very top of the file. Do not edit. 3 | // icon-color: green; icon-glyph: thermometer-half; 4 | // author: Wouter Janson 5 | // website: https://wouterjanson.nl 6 | 7 | // Setup 8 | if (!Keychain.contains("ICY_Password")) { 9 | var alert = new Alert() 10 | alert.title = "ICY Thermostat" 11 | alert.message = "Please first run the 'Set credentials' script, in order to use this script" 12 | alert.present() 13 | return; 14 | } 15 | 16 | let apiUrl = Keychain.get("ICY_API") 17 | let username = Keychain.get("ICY_Username") 18 | let password = Keychain.get("ICY_Password") 19 | let room = Keychain.get("ICY_Room") 20 | 21 | // Login 22 | let loginReq = new Request(apiUrl + "/login") 23 | loginReq.method = "POST" 24 | loginReq.addParameterToMultipart("username", username) 25 | loginReq.addParameterToMultipart("password", password) 26 | 27 | let loginJson = await loginReq.loadJSON() 28 | let token = loginJson['token'] 29 | let uid = loginJson['serialthermostat1'] 30 | 31 | // Get Temperature 32 | let tempReq = new Request(apiUrl + "/data") 33 | tempReq.method = "GET" 34 | tempReq.formData = {"username" : username, "password": password} 35 | tempReq.headers = {"Session-token" : token} 36 | 37 | let tempJson = await tempReq.loadJSON() 38 | let temperature = tempJson['temperature2'] 39 | let targetTemperature = tempJson['temperature1'] 40 | 41 | // Set Temperature 42 | let setReq = new Request(apiUrl + "/data") 43 | setReq.method = "POST" 44 | setReq.addParameterToMultipart("uid", uid) 45 | setReq.addParameterToMultipart("temperature1", `${targetTemperature - 1}` ) 46 | setReq.headers = {"Session-token" : token} 47 | 48 | await setReq.load() 49 | 50 | // Display 51 | let html = ` 52 | 68 | 69 |
70 |

Temperature: ${temperature}℃
Target: ${targetTemperature - 1}℃

71 |
72 | ` 73 | 74 | if (config.runsWithSiri) { 75 | Speech.speak(`I've lowered the target temparature in the ${room} from ${targetTemperature}°C to ${targetTemperature - 1}°C`) 76 | } 77 | 78 | WebView.loadHTML(html, null, new Size(0, 150)) -------------------------------------------------------------------------------- /scripts/ICY - Thermostat/ICY - Temperature up.js: -------------------------------------------------------------------------------- 1 | // Variables used by Scriptable. 2 | // These must be at the very top of the file. Do not edit. 3 | // icon-color: green; icon-glyph: thermometer-half; 4 | // author: Wouter Janson 5 | // website: https://wouterjanson.nl 6 | 7 | // Setup 8 | if (!Keychain.contains("ICY_Password")) { 9 | var alert = new Alert() 10 | alert.title = "ICY Thermostat" 11 | alert.message = "Please first run the 'Set credentials' script, in order to use this script" 12 | alert.present() 13 | return; 14 | } 15 | 16 | let apiUrl = Keychain.get("ICY_API") 17 | let username = Keychain.get("ICY_Username") 18 | let password = Keychain.get("ICY_Password") 19 | let room = Keychain.get("ICY_Room") 20 | 21 | // Login 22 | let loginReq = new Request(apiUrl + "/login") 23 | loginReq.method = "POST" 24 | loginReq.addParameterToMultipart("username", username) 25 | loginReq.addParameterToMultipart("password", password) 26 | 27 | let loginJson = await loginReq.loadJSON() 28 | let token = loginJson['token'] 29 | let uid = loginJson['serialthermostat1'] 30 | 31 | // Get Temperature 32 | let tempReq = new Request(apiUrl + "/data") 33 | tempReq.method = "GET" 34 | tempReq.formData = {"username" : username, "password": password} 35 | tempReq.headers = {"Session-token" : token} 36 | 37 | let tempJson = await tempReq.loadJSON() 38 | let temperature = tempJson['temperature2'] 39 | let targetTemperature = tempJson['temperature1'] 40 | 41 | // Set Temperature 42 | let setReq = new Request(apiUrl + "/data") 43 | setReq.method = "POST" 44 | setReq.addParameterToMultipart("uid", uid) 45 | setReq.addParameterToMultipart("temperature1", `${targetTemperature + 1}` ) 46 | setReq.headers = {"Session-token" : token} 47 | 48 | await setReq.load() 49 | 50 | // Display 51 | let html = ` 52 | 68 | 69 |
70 |

Temperature: ${temperature}℃
Target: ${targetTemperature + 1}℃

71 |
72 | ` 73 | 74 | if (config.runsWithSiri) { 75 | Speech.speak(`I've raised the target temparature in the ${room} from ${targetTemperature}°C to ${targetTemperature + 1}°C`) 76 | } 77 | 78 | WebView.loadHTML(html, null, new Size(0, 150)) -------------------------------------------------------------------------------- /scripts/Trakt.tv Movie Recommendations/Trakt.TV Recommendations.js: -------------------------------------------------------------------------------- 1 | // Variables used by Scriptable. 2 | // These must be at the very top of the file. Do not edit. 3 | // icon-color: red; icon-glyph: film; 4 | 5 | // Trakt: 6 | let traktToken = "" // Trakt Auth Token 7 | let traktApiKey = "" // Trakt ClientID. See https://trakt.tv/oauth/applications 8 | 9 | let traktApiUrl = "https://api.trakt.tv/recommendations/movies" 10 | 11 | // The Movie DB, for posters 12 | let tmdbApiKey = "" // TMDB API Key. See https://www.themoviedb.org/settings/api 13 | 14 | let movieReq = new Request(traktApiUrl) 15 | movieReq.method = "GET" 16 | movieReq.contentType = "application/json" 17 | movieReq.headers = {"content-type": "application/json", "Authorization" : "Bearer " + traktToken, "trakt-api-version" : "2", "trakt-api-key" : traktApiKey} 18 | 19 | let movieJson = await movieReq.loadJSON() 20 | movieJson = shuffle(movieJson) 21 | 22 | let movieTable = new UITable() 23 | for (var i = 0; i < movieJson.length; i++) { 24 | let tmdbId = movieJson[i].ids.tmdb 25 | // Get Poster 26 | let posterReq = new Request(`https://api.themoviedb.org/3/movie/${tmdbId}/images?api_key=${tmdbApiKey}`) 27 | posterReq.method = "GET" 28 | let posterJson = await posterReq.loadJSON() 29 | let posterUrl = "http://image.tmdb.org/t/p/w185" + posterJson.posters[0].file_path 30 | 31 | // Setup Table Row 32 | let row = new UITableRow() 33 | let posterCell = row.addImageAtURL(posterUrl) 34 | let titleCell = row.addText(movieJson[i].title, movieJson[i].year.toString()) 35 | posterCell.widthWeight = 20 36 | titleCell.widthWeight = 80 37 | row.height = 120 38 | row.cellSpacing = 10 39 | 40 | movieTable.addRow(row) 41 | } 42 | 43 | // Present: 44 | if (config.runsWithSiri) { 45 | Speech.speak(`Here are my recommendations.`) 46 | } 47 | QuickLook.present(movieTable) 48 | 49 | function shuffle(array) { 50 | var currentIndex = array.length, temporaryValue, randomIndex; 51 | while (0 !== currentIndex) { 52 | randomIndex = Math.floor(Math.random() * currentIndex); 53 | currentIndex -= 1; 54 | 55 | temporaryValue = array[currentIndex]; 56 | array[currentIndex] = array[randomIndex]; 57 | array[randomIndex] = temporaryValue; 58 | } 59 | return array; 60 | } --------------------------------------------------------------------------------