{"id":20989164,"url":"https://github.com/latchdevel/zwayups","last_synced_at":"2026-04-21T18:36:16.225Z","repository":{"id":145788589,"uuid":"581326194","full_name":"latchdevel/zwayups","owner":"latchdevel","description":"Waveshare UPS HAT battery measures updater for Z-Way devices","archived":false,"fork":false,"pushed_at":"2022-12-23T15:19:52.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T07:46:00.200Z","etag":null,"topics":["hat","ina219","raspberry-pi","raspberrypi","ups","waveshare","z-wave","z-way","zwave","zway"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/latchdevel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-22T21:55:00.000Z","updated_at":"2024-03-11T13:48:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2605b82-0c46-44f7-b7a6-044f85da41fc","html_url":"https://github.com/latchdevel/zwayups","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/latchdevel%2Fzwayups","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2Fzwayups/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2Fzwayups/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2Fzwayups/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/latchdevel","download_url":"https://codeload.github.com/latchdevel/zwayups/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243401482,"owners_count":20285051,"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":["hat","ina219","raspberry-pi","raspberrypi","ups","waveshare","z-wave","z-way","zwave","zway"],"created_at":"2024-11-19T06:24:00.507Z","updated_at":"2025-12-24T18:49:49.792Z","avatar_url":"https://github.com/latchdevel.png","language":"Python","readme":"# UPS battery measures updater for Z-Way devices\n\n## UPS HAT\nWaveshare UPS HAT (B) For Raspberry Pi, 5V Uninterruptible Power Supply (UPS)\n\n- Designed for Raspberry Pi series, compatible with Raspberry Pi 3 / 3B+ / 4B.\n- 2S 18650 LiPo batteries, 7.4v nominal, 8.4v full charge.\n- I2C/SMbus interface to monitoring the batteries voltage, current, power, and remaining capacity in real-time.\n- Protection circuits for overcharge/discharge protection, over current protection, short circuit protection, and reverse protection.\n\nSee Waveshare wiki https://www.waveshare.com/wiki/UPS_HAT_(B)\n\n## Z-Way devices\n\nRequires two Z-Way \"**Virtual Device (JavaScript)**\", one for UPS battery current and one for charge percentage.\n\n![Z-Way UPS devices](Z-Way_UPS_devices.png)\n\nZ-Way server from [Z-Wave.me](https://z-wave.me/)\n\n## Monitor\nPython script `ups_monitor.py` gets continuous measures of UPS battery current and charge percentage to averaging them, and update it Z-Way devices every 10 seconds.\n\nIt must be edit to configure:\n- Z-Way server host or ip, by default: `localhost`\n- Z-Way server tcp port, by default: `8083`\n- Z-Way server user and password or bearer token\n- Z-Way virtual device for UPS battery current mA\n- Z-Way virtual device for UPS battery charge percentage\n  \nIt runs in python2 and python3, and requires `requests` and `smbus` modules.\n\n### Install\n```\npi@raspberrypi:/home/pi $ git clone https://github.com/latchdevel/zwayups.git\npi@raspberrypi:/home/pi $ cd zwayups\npi@raspberrypi:/home/pi/zwayups $ pip install -r requirements.txt\n```\n\nRaspberry Pi linux kernel must be enable I2C/SMBus hardware interface. \nIt can be configured by `raspi-config` or manual edit of `/boot/config.txt` to set `dtparam=i2c_arm=on`.\nAfter reboot i2c kernel modules are loaded.\n```\npi@raspberrypi:/home $ lsmod |grep i2c\ni2c_bcm2835            16384  0\ni2c_dev                20480  0\n```\n### Running\n```\npi@raspberrypi:/home/pi/zwayups $ ./ups_monitor.py\nWaveshare UPS HAT (B) Monitor\nInstant battery current=-192mA charge=94.3%\nUpdating Z-Way devices every 10 seconds\n```\n\n## Manual update \nPython script `ups_get.py` gets instant measures of battery current and charge percentage in JSON format.\n\n```\npi@raspberrypi:/home/pi/zwayups $ ./ups_get.py\n{\"current\":-19,\"charge\":93.0}\n```\n- Negative current value when battery discharging to power the Raspberry Pi.\n- Positive current value when battery charging from external power.\n\nIt can be used to manual update of Z-Way Virtual Device. Code to get value:\n```js\nJSON.parse(system(\"/home/pi/zwayups/ups_get.py\")[1])[\"current\"]\n```\n\nMust be add `/home/pi/zwayups/ups_get.py` to Z-Way config file: `/opt/z-way-server/automation/.syscommands`\n\n# License\nCopyright (c) 2022 Jorge Rivera. All right reserved.\n\nLicense GNU Lesser General Public License v3.0.\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 3 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License \nalong with this library; if not, write to the Free Software Foundation, \nInc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.\n\nSee the [LICENSE](LICENSE.txt) file for license rights and limitations (lgpl-3.0).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flatchdevel%2Fzwayups","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flatchdevel%2Fzwayups","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flatchdevel%2Fzwayups/lists"}