Created
January 3, 2024 15:10
-
-
Save phibo23/ae0f0c966d27a24a47e72db40bcd72fb to your computer and use it in GitHub Desktop.
ICE Portal iOS Widget with Scriptable App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const widget = new ListWidget() | |
const request = new Request('https://iceportal.de/api1/rs/status') | |
// {"connection":true,"serviceLevel":"AVAILABLE_SERVICE","gpsStatus":"LAST_KNOWN_POSITION","internet":"MIDDLE","latitude":50.9862425,"longitude":9.572488166666666,"tileY":109,"tileX":-2,"series":"412","serverTime":1704210660163,"speed":189.0,"trainType":"ICE","tzn":"ICE9474","wagonClass":"FIRST","connectivity":{"currentState":"HIGH","nextState":"UNSTABLE","remainingTimeSeconds":4800},"bapInstalled":true} | |
const json = await request.loadJSON() | |
const { speed } = json | |
widget.addText(speed?.toLocaleString('de', { | |
style: 'unit', | |
unit: 'kilometer-per-hour' | |
})) | |
widget.refreshAfterDate = new Date(Date.now() + 10000) | |
Script.setWidget(widget) | |
Script.complete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment