Package: pichondria
Pichondria LibraryDescriptionPichondria is a Python library designed to communicate with and configure the Pichondria UPS HAT for Raspberry Pi. The Pichondria UPS HAT is a power management solution that provides uninterruptible power supply functionality to Raspberry Pi devices.With the Pichondria library, you can easily interact with the Pichondria UPS HAT using I2C communication from your Raspberry Pi. It allows you to monitor battery status, input voltage, output load, and perform various power management tasks.Key FeaturesRead battery status, voltage, and capacityMonitor input voltage and output loadConfigure UPS settings, such as startup voltage, shutdown voltage, wake-up timer, shutdown timer, and boot-up timerEnable/disable autopilot mode for automatic boot-up after a battery low shutdownInitiate shutdown, reboot, and scheduled shutdown commandsHardwarePichondria hardware specifications and details can be found atPichondria Official WebsiteOverview of functionsFunction NameArgumentsResponseBandwidth UsageRequires Applying to take effectapply_settingsNoneReturns True if settings applied successfully, False if notNANAcheck_shutdownNoneReturns True if shutdown command is received from Pichondria, False if notHigherNAcheck_shutdown_adpichondria_address (hex)Returns True if shutdown command is received from Pichondria, False if notLowerNAenable_acknowledgement_modeNoneReturns True if acknowledgement mode enabling is successful, False if notNANodisable_acknowledgement_modeNoneReturns True if acknowledgement mode disabling is successful, False if notNANocheck_acknowledgement_modeNoneReturns True if acknowledgement mode is enabled, False otherwiseNANAenable_autopilotNoneReturns True if autopilot mode enabling is successful, False if notNANodisable_autopilotNoneReturns True if autopilot mode disabling is successful, False if notNANocheck_autopilot_modeNoneReturns True if autopilot mode is enabled, False otherwiseNANAget_battery_voltageNoneReturns the battery voltage as a floatHigherNAget_battery_voltage_adpichondria_address (hex)Returns the battery voltage as a floatLowerNAget_bootup_timerNoneReturns the boot-up timer value as an intNANAget_input_voltageNoneReturns the input voltage as a floatHigherNAget_input_voltage_adpichondria_address (hex)Returns the input voltage as a floatLowerNAget_output_voltageNoneReturns the output voltage as a floatHigherNAget_output_voltage_adpichondria_address (hex)Returns the output voltage as a floatLowerNAget_pichondria_addressNoneReturns the address of the Pichondria deviceNANAget_shutdown_timerNoneReturns the shutdown timer value as an intNANAget_shutdown_voltageNoneReturns the shutdown voltage as a floatNANAget_startup_voltageNoneReturns the startup voltage as a floatNANAget_wake_up_timerNoneReturns the wake-up timer value as an intNANAinput_availabilityNoneReturns True if input power is available, False if notHigherNAinput_availability_adpichondria_address (hex)Returns True if input power is available, False if notLowerNAis_chargingNoneReturns True if the battery is charging, False if notHigherNAis_charging_adpichondria_address (hex)Returns True if the battery is charging, False if notLowerNAreq_power_restore_shutdownNoneReturns True if power restore shutdown requested successfully, False if notHigherNAreq_power_restore_shutdown_adpichondria_address (hex)Returns True if power restore shutdown requested successfully, False if notLowerNAreq_rebootNoneReturns True if reboot requested successfully, False if notHigherNAreq_reboot_adpichondria_address (hex)Returns True if reboot requested successfully, False if notLowerNAreq_scheduled_rebootNoneReturns True if scheduled reboot requested   successfully, False if notHigherNAreq_scheduled_reboot_adpichondria_address (hex)Returns True if scheduled reboot requested   successfully, False if notLowerNAreq_shutdownNoneReturns True if shutdown requested successfully, False if notHigherNAreq_shutdown_adpichondria_address (hex)Returns True if shutdown requested successfully, False if notLowerNAsend_acknowledgementNoneReturns True if acknowledgement sent successfully, False if notNANAset_bootup_timertimer (int)Returns True if boot-up timer set successfully, False if notNAYesset_pichondria_addressaddress (hex)Returns True if successful, False if notNANoset_shutdown_timertimer (int)Returns True if shutdown timer set successfully, False if notNAYesset_shutdown_voltagevoltage (float)Returns True if shutdown voltage set successfully, False if notNAYesset_startup_voltagevoltage (float)Returns True if startup voltage set successfully, False if notNAYesset_wake_up_timertimer (int)Returns True if wake-up timer set successfully, False if notNAYesWhen communicating with the Pichondria, since the address of Pichondria is configurable, in normal usage, the Raspberry Pi reads the address of Pichondria from the EEPROM and then communicates with the address read from EEPROM. To lower the communication required, you can use 'get_pichondria_address( )' and then pass on the address to all functions which end with _ad. This reduces the number of bits by ~33% in the I2C bus.Some functions need 'apply_settings( )' to take effect. If any variables are changed in EEPROM and not applied, the system will not work as expected. Always apply changes.InstallationYou can installpichondriausing pip. Make sure you have Python 3.6+ installed.pipinstallpichondriaUsageTo get started with Pichondria, import the library and create an instance of the Pichondria class:Creating instance of Pichondria:importpichondriaGetting the Pichondria I2C Addresspichondria_address=pichondria.get_pichondria_address()Setting the Pichondria I2C Addressnew_address=0x51# Replace this with the desired address (e.g., 0x51)success=pichondria.set_pichondria_address(new_address)ifsuccess:print(f"Pichondria I2C Address set to {hex(new_address)} successfully!")else:print("Failed to set Pichondria I2C Address.")Checking Input Availabilityinput_available=pichondria.input_availability()Checking Charging Statuscharging_status=pichondria.is_charging()Getting Input Voltageinput_voltage=pichondria.get_input_voltage()Getting Output Voltageoutput_voltage=pichondria.get_output_voltage()Getting Battery Voltagebattery_voltage=pichondria.get_battery_voltage()Applying Settingspichondria.apply_settings()Configuring Startup Voltagepichondria.set_startup_voltage(3.4)pichondria.apply_changes()Configuring Shutdown Voltagepichondria.set_shutdown_voltage(3.4)pichondria.apply_changes()Configuring Wake-Up Timerpichondria.set_wake_up_timer(1800)pichondria.apply_changes()Configuring Shutdown Timerpichondria.set_shutdown_timer(120)pichondria.apply_changes()Configuring Boot-Up Timerpichondria.set_bootup_timer(30)pichondria.apply_changes()Enabling/Disabling/Checking Autopilot Modepichondria.enable_autopilot()pichondria.disable_autopilot()pichondria.check_autopilot_mode()Enabling/Disabling/Checking Acknowledgement Modepichondria.enable_acknowledgement_mode()pichondria.disable_acknowledgement_mode()pichondria.check_acknowledgement_mode()Sending Acknowledgementpichondria.send_acknowledgement()Checking Shutdown Requestshutdown_requested=pichondria.check_shutdown()ifshutdown_requested:ifacknowledgement_mode_enabled:pichondria.send_acknowledgement()subprocess.run(["sudo","shutdown","now"])LicensePichondria code is released under the MIT LicenseContactFor support or any inquiries, you can reach out to us atsupport@pichondria.com