Simple App - Refresh of HTTP Requests

Dear Tidbyt-Developer

As a beginner, I have a question about the refresh of the app. There is function which gathers data from a public API and returns the values for later usage. In main, the function is executed, the values are formatted and shown on the display.

I have pushed the App locally for testing purposes with

pixlet render
pixlet push --installation-id my-id ...

But, the App still shows the same values, there is no refresh. How can I force it, if the App rotates or by time, the values are updated?

Here is the function:

def get_delay():
        response = http.get(STATIONTABLE_URL)
        if response.status_code != 200:
            fail("Stationtable request failed with status %d", response.status_code)
        json_data = response.json()  # Parse the response as JSON
        if "stationboard" in json_data and len(json_data["stationboard"]) > 0:
            delay = json_data["stationboard"][0]["stop"]["delay"]
            name = json_data["station"]["name"]
            departure = json_data["stationboard"][0]["stop"]["departure"]
            return delay, name, departure
            return None


This is the classic misunderstanding of how the tidbyt works. The tidbyt is just an image display device. The app doesn’t actually run on the tidbyt so it can’t ever update itself. You need to rerun pixlet render to actually re-run the starlark code.

Hi Tavis

Thanks for quick reply and clarification - I have created a local crontab which pushes the app every 5 minutes to get the actual date.

But how are the app developer doing that for an app which needs actual date like the installed Weather app?


If you get your app published into the community repo then the script gets run by the tidbyt servers on a schedule. If not then you need to run it via cron yourself.

1 Like

Thank you, now I try to give my best to bring it to an app .


@mbg_ch just saw and loaded your SBB app and thinking it might have ZVV schedules/stops as well. Any chance you’d be interested in sharing your code for this so I can adapt a ZVV model?

Sure, I check in the code in GitHub this week and drop you the link.