I am using Python to print() a value for display, extracted from API output.
How do I set an internal variable using a Python script, and use the time of last update to test for whether to request a new value?
I do not want the API to be called more than once per hour. The print() output should be stored for display until it is at least an hour old, or even 12 hours old, before a new value is requested.
I tried setting the options not to run the script at every appearance and the update schedule to 43200 seconds (= 12 hours) but it still used up my API quota in only a few days.
BetterTouchTool doesn’t have any direct python bindings or similar, thus you‘d need to call the set_number_variable or set_string_variable and get_number_variable apple script functions via osascript command line utility. (Using Apple Script or JXA · GitBook). An alternative would be to enable BTT's built in webserver and call that from your pyhton script: Using HTTP Requests / Webserver · GitBook
However BTT does support Java Script run directly within BTT, so a better way is to either fully convert your python script to java script or at least run the python script from within BTT‘s Java Script and put that part of the logic into the Java Script before calling your python script. In case you want to try: ChatGPT is good at converting Python Scripts to Java Script, just make sure to mention this is in a special context and also point it to BTT's Java Script documentation: