matthewwall / weewx-twitter

tweet your weather data
3 stars 0 forks source link

Posting on Twitter at fixed time #4

Open UD-37 opened 2 years ago

UD-37 commented 2 years ago

Is it possible to post weather data on a Twitter account at fixed time (like 0h00, 6h00, 12h00 and 18h00) ?

Here is the code I have (from WeeWX Google-group), but if WeeWX starts at 4H31: data are posted on Twitter at 6H35, 12H35, 18H35 then 0H35. So, is there a way to include minutes in the process ?

        ts = time.localtime()
        if (ts.tm_hour != 0 and ts.tm_hour != 6 and ts.tm_hour != 12 and ts.tm_hour != 18):
            logdbg("This is not hour to tweet: %d" % ts.tm_hour)
            return
jdb235 commented 1 year ago

Try using tm_min:

ts = time.localtime()
    if ts.tm_hour not in (0,6,12,18) or ts.tm_min != 0:
        logdbg("This is not hour to tweet: %d" % ts.tm_hour)
            return

That should only tweet at 0:00, 06:00, 12:00 or 18:00. I'm not certain if this will work if the archive interval is longer than 1 minute though