Skip to content

Instantly share code, notes, and snippets.

@phibo23
Created January 3, 2024 15:10
Show Gist options
  • Save phibo23/ae0f0c966d27a24a47e72db40bcd72fb to your computer and use it in GitHub Desktop.
Save phibo23/ae0f0c966d27a24a47e72db40bcd72fb to your computer and use it in GitHub Desktop.
ICE Portal iOS Widget with Scriptable App
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