{"id":15653759,"url":"https://github.com/syssi/esphome-apc-ups","last_synced_at":"2025-04-15T06:54:25.217Z","repository":{"id":170376481,"uuid":"637030937","full_name":"syssi/esphome-apc-ups","owner":"syssi","description":"ESPHome component to monitor and control a APC UPS via RS232","archived":false,"fork":false,"pushed_at":"2025-03-03T10:11:29.000Z","size":79,"stargazers_count":47,"open_issues_count":4,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-15T06:54:18.916Z","etag":null,"topics":["apc","esphome","esphome-component","hacktoberfest","ups"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syssi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"buy_me_a_coffee":"syssi"}},"created_at":"2023-05-06T09:41:21.000Z","updated_at":"2025-03-26T17:13:47.000Z","dependencies_parsed_at":"2024-05-16T02:16:50.660Z","dependency_job_id":"07ca6ab3-fa6a-431f-b90d-f761b9c39953","html_url":"https://github.com/syssi/esphome-apc-ups","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.08333333333333337,"last_synced_commit":"8d2053ff76a1678c65cb109140f940f07fd31872"},"previous_names":["syssi/esphome-apc-ups"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syssi%2Fesphome-apc-ups","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syssi%2Fesphome-apc-ups/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syssi%2Fesphome-apc-ups/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syssi%2Fesphome-apc-ups/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syssi","download_url":"https://codeload.github.com/syssi/esphome-apc-ups/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023710,"owners_count":21199958,"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":["apc","esphome","esphome-component","hacktoberfest","ups"],"created_at":"2024-10-03T12:46:57.951Z","updated_at":"2025-04-15T06:54:25.198Z","avatar_url":"https://github.com/syssi.png","language":"C++","funding_links":["https://buymeacoffee.com/syssi","https://www.buymeacoffee.com/syssi"],"categories":[],"sub_categories":[],"readme":"# esphome-apc-ups\n\n![GitHub actions](https://github.com/syssi/esphome-apc-ups/actions/workflows/ci.yaml/badge.svg)\n![GitHub stars](https://img.shields.io/github/stars/syssi/esphome-apc-ups)\n![GitHub forks](https://img.shields.io/github/forks/syssi/esphome-apc-ups)\n![GitHub watchers](https://img.shields.io/github/watchers/syssi/esphome-apc-ups)\n[![\"Buy Me A Coffee\"](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://www.buymeacoffee.com/syssi)\n\nESPHome component to monitor and control a APC UPS via RS232\n\n## Supported devices\n\n* APC SU420INET (firmware `21.3.I`)\n* APC SUVS420I (firmware `42.L.I`)\n* APC SUA1000I (firmware `652.13.I`)\n\n## Requirements\n\n* [ESPHome 2024.6.0 or higher](https://github.com/esphome/esphome/releases).\n* Generic ESP32/ESP8266 board\n\n## Schematics\n\n```\n                 RS232                     UART-TTL\n┌───────────┐              ┌──────────┐                ┌─────────┐\n│           │              │          │\u003c----- RX -----\u003e│         │\n│           │\u003c---- TX ----\u003e│  RS232   │\u003c----- TX -----\u003e│ ESP32/  │\n│  APC UPS  │\u003c---- RX ----\u003e│  to TTL  │\u003c----- GND ----\u003e│ ESP8266 │\n│           │\u003c---- GND ---\u003e│  module  │\u003c-- 3.3V VCC --\u003e│         │\u003c--- VCC\n│           │              │          │                │         │\u003c--- GND\n└───────────┘              └──────────┘                └─────────┘\n```\n\n### D-SUB 9P connector\n\n| Pin | Purpose      | MAX3232 pin       |\n|:---:| :----------- | :---------------- |\n|  1  | RX           | P14 (DOUT1)       |\n|  2  | TX           | P13 (RIN1)        |\n|  3  |              |                   |\n|  4  |              |                   |\n|  5  |              |                   |\n|  6  |              |                   |\n|  7  |              |                   |\n|  8  |              |                   |\n|  9  | GND          | P15 (GND)         |\n\n### MAX3232\n\n| Pin          | Label        | ESPHome     | ESP8266 example  | ESP32 example |\n| :----------- | :----------- | :---------- | :--------------- | :------------ |\n| P11 (DIN1)   | TXD          | `tx_pin`    | `GPIO4`          | `GPIO16`      |\n| P12 (ROUT1)  | RXD          | `rx_pin`    | `GPIO5`          | `GPIO17`      |\n| P16 (VCC)    | VCC          |             |                  |               |\n| P15 (GND)    | GND          |             |                  |               |\n\n## Installation\n\nYou can install this component with [ESPHome external components feature](https://esphome.io/components/external_components.html) like this:\n```yaml\nexternal_components:\n  - source: github://syssi/esphome-apc-ups@main\n```\n\nor just use the `esp32-example.yaml` as proof of concept:\n\n```bash\n# Install esphome\npip3 install esphome\n\n# Clone this external component\ngit clone https://github.com/syssi/esphome-apc-ups.git\ncd esphome-apc-ups\n\n# Create a secrets.yaml containing some setup specific secrets\ncat \u003e secrets.yaml \u003c\u003cEOF\nwifi_ssid: MY_WIFI_SSID\nwifi_password: MY_WIFI_PASSWORD\n\nmqtt_host: MY_MQTT_HOST\nmqtt_username: MY_MQTT_USERNAME\nmqtt_password: MY_MQTT_PASSWORD\nEOF\n\n# Validate the configuration, create a binary, upload it, and start logs\n# If you use a esp8266 run the esp8266-examle.yaml\nesphome run esp32-example.yaml\n\n```\n\n## Example response all sensors enabled\n\n```\n[apc_ups:286]: Sending polling command : Y with length 1\n[apc_ups:112]: Decode Y\n[apc_ups:286]: Sending polling command : Q with length 1\n[apc_ups:153]: Decode Q\n[sensor:094]: 'apc-ups status bitmask': Sending state 8.00000  with 0 decimals of accuracy\n[binary_sensor:036]: 'apc-ups runtime calibration': Sending state OFF\n[binary_sensor:036]: 'apc-ups smart trim': Sending state OFF\n[binary_sensor:036]: 'apc-ups smart boost': Sending state OFF\n[binary_sensor:036]: 'apc-ups on line': Sending state ON\n[binary_sensor:036]: 'apc-ups on battery': Sending state OFF\n[binary_sensor:036]: 'apc-ups output overloaded': Sending state OFF\n[binary_sensor:036]: 'apc-ups battery low': Sending state OFF\n[binary_sensor:036]: 'apc-ups replace battery': Sending state OFF\n[apc_ups:286]: Sending polling command : B with length 1\n[apc_ups:117]: Decode B\n[sensor:094]: 'apc-ups battery voltage': Sending state 13.61000 V with 2 decimals of accuracy\n[apc_ups:286]: Sending polling command : F with length 1\n[apc_ups:123]: Decode F\n[sensor:094]: 'apc-ups grid frequency': Sending state 50.00000 Hz with 2 decimals of accuracy\n[apc_ups:286]: Sending polling command : L with length 1\n[apc_ups:135]: Decode L\n[sensor:094]: 'apc-ups grid voltage': Sending state 231.80000 V with 1 decimals of accuracy\n[apc_ups:286]: Sending polling command : O with length 1\n[apc_ups:141]: Decode O\n[sensor:094]: 'apc-ups ac output voltage': Sending state 231.80000 V with 1 decimals of accuracy\n[apc_ups:286]: Sending polling command : P with length 1\n[apc_ups:147]: Decode P\n[sensor:094]: 'apc-ups ac output load': Sending state 9.10000 % with 1 decimals of accuracy\n[apc_ups:286]: Sending polling command : f with length 1\n[apc_ups:171]: Decode f\n[sensor:094]: 'apc-ups state of charge': Sending state 100.00000 % with 1 decimals of accuracy\n[apc_ups:286]: Sending polling command : j with length 1\n[apc_ups:177]: Decode j\n[sensor:094]: 'apc-ups estimated runtime': Sending state 42.00000 min with 0 decimals of accuracy\n[apc_ups:286]: Sending polling command : G with length 1\n[apc_ups:129]: Decode G\n[text_sensor:064]: 'apc-ups cause of last transfer': Sending state 'S'\n```\n\n## Protocol\n\nSee [kirbah.github.io/apc-ups/](https://kirbah.github.io/apc-ups/).\n\n## Known issues\n\nNone.\n\n## Debugging\n\nIf this component doesn't work out of the box for your device please update your configuration to increase the log level to see details about the UART traffic:\n\n```\nlogger:\n  level: DEBUG\n\nuart:\n  - id: uart_0\n    baud_rate: 2400\n    tx_pin: ${tx_pin}\n    rx_pin: ${rx_pin}\n    debug:\n      direction: BOTH\n      dummy_receiver: false\n      after:\n        delimiter: \"\\r\"\n      sequence:\n        - lambda: UARTDebug::log_string(direction, bytes);\n```\n\n## References\n\n* https://github.com/kirbah/apc-ups\n* http://www.apcupsd.org/manual/#apc-smart-protocol\n* https://github.com/ssieb/custom_components/tree/master/components/apcups\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyssi%2Fesphome-apc-ups","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyssi%2Fesphome-apc-ups","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyssi%2Fesphome-apc-ups/lists"}