aceinnolab / Inkycal

Create awesome e-paper dashboards within minutes! Modularity? Check! Python3? Check? Works on Raspberry Pi Zero W? Check! Support for own modules? Check!
https://aceinnolab.github.io/Inkycal/
GNU General Public License v3.0
1.21k stars 128 forks source link

[Enhancement]: Improve PiSugar support #370

Closed kfezer closed 2 months ago

kfezer commented 3 months ago

Describe the bug When trying to run inky_run.py and pysugar board is off, bet this error:

21-08-2024 10:44:54 | inkycal.main |  INFO: name : Weather size : 984x256 px
21-08-2024 10:44:54 | inkycal.main |  INFO: PiSugar support enabled.
21-08-2024 10:44:55 | inkycal.main |  INFO: PiSugar battery capacity: None%
Traceback (most recent call last):
  File "/home/inky/Inkycal/inky_run.py", line 43, in <module>
    asyncio.run(run())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/inky/Inkycal/inky_run.py", line 18, in run
    inky = Inkycal(render=True, use_pi_sugar=True, shutdown_after_run=True)
  File "/home/inky/Inkycal/inkycal/main.py", line 168, in __init__
    if self.battery_capacity < 20:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

To Reproduce Steps to reproduce the behavior:

  1. With rpi plugged in, run inky_run.py

Expected behavior Should handle the error of type better.

github-actions[bot] commented 3 months ago

Hi there and welcome to Inkycal. Thanks for opening this issue. As this is your first issue in this repository, please read through the contributing guidelines

aceisace commented 3 months ago

Hi @kfezer and thanks for reporting the issue. Yes, it seems this needs some improvements as the battery level cannot be read if the PiSugar board is off. Would you be willing to help test this functionality as I do not use the PiSugar on my build? If yes, I'll have a fix ready soon and will provide you with some instructions on how to test the fix. If it works for you, then this can be made public.

aceisace commented 2 months ago

Okay, I got a fix ready for this and it's now available. Please run the following to get the patch;

cd ~/Inkycal && source venv/bin/activate
git pull
python inky_run.py

If something shouldn't work as expected, please re-open the issue