1 """A sensor platform which detects underruns and capped status from the official Raspberry Pi Kernel.
3 Minimal Kernel needed is 4.14+
8 from rpi_bad_power
import UnderVoltage, new_under_voltage
11 BinarySensorDeviceClass,
19 _LOGGER = logging.getLogger(__name__)
21 DESCRIPTION_NORMALIZED =
"Voltage normalized. Everything is working as intended."
22 DESCRIPTION_UNDER_VOLTAGE = (
23 "Under-voltage was detected. Consider getting a uninterruptible power supply for"
30 config_entry: ConfigEntry,
31 async_add_entities: AddEntitiesCallback,
33 """Set up rpi_power binary sensor."""
34 under_voltage = await hass.async_add_executor_job(new_under_voltage)
39 """Binary sensor representing the rpi power status."""
41 _attr_device_class = BinarySensorDeviceClass.PROBLEM
42 _attr_entity_category = EntityCategory.DIAGNOSTIC
43 _attr_icon =
"mdi:raspberry-pi"
44 _attr_name =
"RPi Power status"
45 _attr_unique_id =
"rpi_power"
47 def __init__(self, under_voltage: UnderVoltage) ->
None:
48 """Initialize the binary sensor."""
52 """Update the state."""
56 _LOGGER.warning(DESCRIPTION_UNDER_VOLTAGE)
58 _LOGGER.debug(DESCRIPTION_NORMALIZED)
None __init__(self, UnderVoltage under_voltage)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)