astro-pi / python-sense-hat

Source code for Sense HAT Python library
https://sense-hat.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
505 stars 253 forks source link

Unable to initialize old Sense HAT after update to 2.3.1 #121

Closed dbenesj closed 2 years ago

dbenesj commented 2 years ago

After the update to version 2.3.1 I'm not any more able initialize the library with the old/original/v1 Sense HAT. It complains that TCS34725 color sensor is not available.

$ uname -a
Linux malina4 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux
$ cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sense_hat import SenseHat
>>> sense = SenseHat()
WARNING:root:Failed to initialise TCS34725 colour sensor. (sensor not present)
$ pip freeze | grep sense
sense-hat==2.3.1
$ tail /var/log/apt/history.log
...
Upgrade: ... python3-sense-hat:arm64 (2.2.0-2, 2.3.1-1) ...
...

It worked properly before the update to version 2.3.1 (from version 2.2.0)

Is there some way how to tell the library to not try to initiate the color sensor?

G3zz commented 2 years ago

Hi, This is just a warning, and not an error - you can still use the library as it was in previous versions Geraint

dbenesj commented 2 years ago

Aha, I see, thank you. Can this warning be somehow muted?

I'm asking because I'm using the library from the script that is used in crontab (I'm logging values from Sense HAT this way to some online storage). Because of that when there is some output, it sends me an email. Until the upgrade it sends an email only in case of some problem. Which is a nice behavior. With this warning, email is sent with each execution.

dbenesj commented 2 years ago

Solved by changing the logging level

...
import logging
from sense_hat import SenseHat
logging.getLogger().setLevel(logging.ERROR)
sense = SenseHat()
logging.getLogger().setLevel(logging.WARNING)
...