Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adafruit_io logging causing halt (in 0.0.8) #77

Closed
retropangy opened this issue Sep 6, 2022 · 7 comments
Closed

adafruit_io logging causing halt (in 0.0.8) #77

retropangy opened this issue Sep 6, 2022 · 7 comments

Comments

@retropangy
Copy link

adafruit_io upload appears to be causing my grow to halt with a red flashing light. Suspect for some reason it's not handling throttling at the adafruit end (it did before) and returning False, which means that

    if not enviro.upload_readings():
      enviro.halt("! reading upload failed")

in main.py is causing a halt. Could be wrong though!

@lowfatcode
Copy link
Member

That's correct, it's alerting you that an error occurred. If it's throttling you need to either reduce your upload frequency, remove some readings, or pay for a Pro plan!

@retropangy
Copy link
Author

It wasn't doing that before however - it was throttling, but it backed off and tried again rather than halting. It looks like the entire section to handle that situation has been removed;

        if result.status_code == 429:
          result.close()
          logging.info(f"  - rate limited, cooling off for thirty seconds")
          time.sleep(30)
          # try the request again
          result = urequests.post(url, json=payload, headers=headers)

and I think even if that failed it didn't halt.

I should probably point out that I'm using the provisioning defaults for the Grow at all points. I feel that it should be able to handle uploading to one of the default destinations at the defaults rates without having to have a pro plan - that's just going to put users off. I'm going to try reverting to the original adafruit_io.py in the meantime as at least it worked!

@retropangy
Copy link
Author

@lowfatcode - just also noticed that it now causes a halt if it can't upload for any reason, e.g. the Pico W can't connect to wifi. Does a halt stop any further processing (i.e. does it wake up again in 15 minutes and try again or stay halted)? If so that could be a critical failure - if you're away for two weeks, the wifi glitches for a few minutes two days in and you've got dead plants on your return.

I have altered the new adafruit_io.py to try two more times with 60 seconds sleep inbetween which now seems to be keeping things stable (albeit with one further halt because it couldn't connect to wifi for some unknown reason) but I feel strongly that this should not be a closed issue - it just does not work as well as the previous version.

@lowfatcode
Copy link
Member

Yes, it was backing off before but this isn't a viable solution when on battery power as it substantially increases the drain on the battery - the correct answer is to increase your upload frequency, remove some readings, or pay for pro!

A halt is really just a normal sleep with attached error log entry and blinking red LED to alert the user - so it wakes up again as normal and will actually clear the error (blinking LED) if everything goes OK.

@retropangy
Copy link
Author

Good news on the halt being essentially cosmetic, that's reassuring! I appreciate that the battery usage of waiting and retrying is higher, but compared to over doubling the number of upload sessions it must be a close thing, especially as I imagine running the pumps is going to swamp usage to some degree . (And yes, there is Pro, but as I say it's a bit of an ask for casual users.)

Probably my best bet is to reduce the number of data points in general (e.g drop luminence and battery voltage, maybe pressure) and upload a little more frequently. Hopefully simple enough to do (he says, with little hope!)

@retropangy
Copy link
Author

Of course, now I run into another problem which is that the RTC has drifted into the future so I'm getting errors coming back from adafruit.io because there is date being logged that is in the future as far as its concerned - the backing off hid that because by the time it actually uploaded it was in the past! More halts because of it. The ntp fetch is only done if the year has reset, so I've had to alter the code in enviro/init.py so that is_clock_set() only returns true if the year is above 2020 and it's not between midnight and half-past midnight - so hopefully it will sync once (or twice) a day.

@RedDogUK
Copy link

RedDogUK commented Sep 11, 2022

@lowfatcode, I think the Adafruit IO upload script needs to revert back to v0.0.2 (or a version similar to v0.0.2) where the script allows for pauses in the upload when reaching the upload limit of 30 data points per minute (for a free account).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants