Debian Codegraph @

README.md

raw symbols SCIP
1 # rpi-bad-power
2 A Python library to detect bad power supply on Raspberry Pi. This library is mainly built for the [Raspberry Pi Power Supply Checker](https://www.home-assistant.io/integrations/rpi_power/) integration of [HomeAssistant](https://github.com/home-assistant/core). It should also work for other purpose.
3
4 ## Compatibility
5
6 This library only works on kernel 4.14+. It supports getting the under voltage bit from different entries.
7
8 Related PRs:
9 - [raspberrypi/linux#2397](https://github.com/raspberrypi/linux/pull/2397): `/sys/devices/platform/soc/soc:firmware/get_trottled`
10 - [raspberrypi/linux#2706](https://github.com/raspberrypi/linux/pull/2706): `/sys/class/hwmon/hwmon0/in0_lcrit_alarm`
11
12 ## Usage
13
14 Here is an example on how to use this library.
15
16 ```python
17 from rpi_bad_power import new_under_voltage
18
19 under_voltage = new_under_voltage()
20 if under_voltage is None:
21 print("System not supported.")
22 elif under_voltage.get():
23 print("Under voltage detected.")
24 else:
25 print("Voltage is normal.")
26 ```
27
28 ## Credits
29
30 Some of the code are based on [custom-components/sensor.rpi_power](https://github.com/custom-components/sensor.rpi_power) maintained by [@swetoast](https://github.com/swetoast).