{"id":18871947,"url":"https://github.com/pisugar/pisugar-power-manager","last_synced_at":"2025-04-14T15:33:05.108Z","repository":{"id":49634667,"uuid":"196549513","full_name":"PiSugar/pisugar-power-manager","owner":"PiSugar","description":"Management program for PiSugar 2","archived":false,"fork":false,"pushed_at":"2022-02-10T18:56:47.000Z","size":1847,"stargazers_count":12,"open_issues_count":4,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T18:58:44.464Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PiSugar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-12T09:22:38.000Z","updated_at":"2025-02-09T17:18:51.000Z","dependencies_parsed_at":"2022-09-17T03:51:24.390Z","dependency_job_id":null,"html_url":"https://github.com/PiSugar/pisugar-power-manager","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiSugar%2Fpisugar-power-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiSugar%2Fpisugar-power-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiSugar%2Fpisugar-power-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiSugar%2Fpisugar-power-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PiSugar","download_url":"https://codeload.github.com/PiSugar/pisugar-power-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248906765,"owners_count":21181213,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T05:28:02.125Z","updated_at":"2025-04-14T15:33:04.120Z","avatar_url":"https://github.com/PiSugar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pisugar-power-manager\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"320\" src=\"https://raw.githubusercontent.com/JdaieLin/PiSugar/master/logo.jpg\"\u003e\n\u003c/p\u003e\n\n### Management program for PiSugar 2\n#### Note: python version will be deprecated, we had migranted to rust.\n#### https://github.com/PiSugar/pisugar-power-manager-rs\n\nInstall\n```\n# before installation\n\n# turn on the i2c interface on raspbian.\n# make sure there's no other phat using address 0x32 or 0x75\n# make sure your python version is 3.6\n\n# check if device 0x32 and 0x75 work. \n# If you can't find them or find some meaningless random code, please reattach the battery module and try again. \ni2cdetect -y 1\ni2cdump -y 1 0x32\ni2cdump -y 1 0x75\n\n# install\napt-get update\napt-get install python3-pyqt5 pyqt5-dev-tools\npip3 install smbus2 websockets\n\n```\n\nStart the core with Web UI:\n```\n$ python3 core/PiSugarCore.py\n\n# core program will host an http server at port 8000\n# please visit http://\u003cip of your pi\u003e:8000\n\n# core program will also create a unix domain socket file: /tmp/pisugar.sock\n# use following commands to get / set data from the battery\n\n# get model  (pisugar model)\n# get battery  (battery level percent)\n# get battery_v  (lithium battery votage)\n# get battery_i  (lithium battery current)\n# get battery_charging  (charging status)\n# get rtc_time  (rtc time string)\n# get rtc_time_list  (rtc time in python list)\n# get rtc_alarm_flag  (rtc alarm flag)\n# get safe_shutdown_level\n# get alarm type (1: daily alarm, 0: off)\n# get alarm time (alarm timestamp)\n# get alarm type (alarm week repeat)\n# get button enable \u003ctype\u003e (type: single/double/long)\n# get button shell \u003ctype\u003e (type: single/double/long)\n\n# rtc_clean_flag  (clean alarm flag)\n# rtc_pi2rtc  (sync time from Pi to rtc)\n# rtc_alarm_set  (set auto wake up alarm)\n# rtc_alarm_disable  (disable wake up alarm)\n# rtc_test_wake (test wake in 1min30sec)\n# set_button_enable (argv1: single/double/long  argv2: 1/0)\n# set_button_shell (argv1: single/double/long  argv2: shell script to execute)\n# set_safe_shutdown_level (e.g. -1 / 3 / 5)\n\n# e.g. get battery level precentage\n$ echo get battery | nc -U /tmp/pisugar.sock\n63.15938281249997\n\n# e.g. set auto wake up alarm on 15:39:00 repeat on Sun, Mon, Tue, Wed, Sat\n$ echo rtc_alarm_set 0,39,15,0,0,0,0 0b1001111 | nc -U /tmp/pisugar.sock\nDone.\n\n\n```\n\nStart with Destop UI (not finished yet):\n```\n$ export DISPLAY=:0\n$ python3 app.py\n\n```\n\n#### Architecture diagram\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"688px\" src=\"https://raw.githubusercontent.com/PiSugar/pisugar-power-manager/master/diagram.jpg\"\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpisugar%2Fpisugar-power-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpisugar%2Fpisugar-power-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpisugar%2Fpisugar-power-manager/lists"}