feat: Add oplats Home Assistant custom integration for bill management#1
Merged
CodekExplor merged 3 commits intomainfrom Apr 13, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/CodekExplor/Bills-ha/sessions/c1d50f92-e391-4883-a759-a0eb229bbd27 Co-authored-by: CodekExplor <24770587+CodekExplor@users.noreply.github.com>
…te import to top of sensor.py Agent-Logs-Url: https://github.com/CodekExplor/Bills-ha/sessions/c1d50f92-e391-4883-a759-a0eb229bbd27 Co-authored-by: CodekExplor <24770587+CodekExplor@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add custom integration for manual payment tracking in Home Assistant
feat: Add Apr 13, 2026
oplats Home Assistant custom integration for bill management
CodekExplor
approved these changes
Apr 13, 2026
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Home Assistant custom integration (custom_components/oplats/) for manual bill/payment tracking with persistent storage, service-based CRUD operations, and aggregate sensors for unpaid/overdue/next-due insights.
Changes:
- Added core data layer (
BillsCoordinator) using HAStorefor persistence and bill state transitions (paid/unpaid). - Registered HA services (
oplats.add_bill,update_bill,delete_bill,mark_paid,mark_unpaid) and added three aggregate sensors. - Added config flow, Polish translations, service descriptions, and a full README with install/usage examples.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
README.md |
Documents installation/configuration and service usage examples for the new integration. |
custom_components/oplats/__init__.py |
Sets up the config entry, forwards platforms, and registers bill-management services. |
custom_components/oplats/config_flow.py |
Adds a single-instance UI config flow. |
custom_components/oplats/const.py |
Defines domain, storage keys, bill field names, and sensor constants. |
custom_components/oplats/coordinator.py |
Implements persistent CRUD and paid/unpaid operations with listener notifications. |
custom_components/oplats/sensor.py |
Adds three aggregate sensors driven by coordinator updates. |
custom_components/oplats/services.yaml |
Defines service metadata/selectors for HA UI. |
custom_components/oplats/translations/pl.json |
Provides Polish UI translations for config flow and services. |
custom_components/oplats/manifest.json |
Declares the new integration’s metadata and config-flow support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+137
to
+156
| if not hass.services.has_service(DOMAIN, "add_bill"): | ||
| hass.services.async_register( | ||
| DOMAIN, "add_bill", handle_add_bill, schema=SERVICE_ADD_BILL_SCHEMA | ||
| ) | ||
| if not hass.services.has_service(DOMAIN, "update_bill"): | ||
| hass.services.async_register( | ||
| DOMAIN, "update_bill", handle_update_bill, schema=SERVICE_UPDATE_BILL_SCHEMA | ||
| ) | ||
| if not hass.services.has_service(DOMAIN, "delete_bill"): | ||
| hass.services.async_register( | ||
| DOMAIN, "delete_bill", handle_delete_bill, schema=SERVICE_BILL_ID_SCHEMA | ||
| ) | ||
| if not hass.services.has_service(DOMAIN, "mark_paid"): | ||
| hass.services.async_register( | ||
| DOMAIN, "mark_paid", handle_mark_paid, schema=SERVICE_BILL_ID_SCHEMA | ||
| ) | ||
| if not hass.services.has_service(DOMAIN, "mark_unpaid"): | ||
| hass.services.async_register( | ||
| DOMAIN, "mark_unpaid", handle_mark_unpaid, schema=SERVICE_BILL_ID_SCHEMA | ||
| ) |
Comment on lines
+145
to
+147
| bill[FIELD_PAID] = True | ||
| bill[FIELD_PAYMENT_DATE] = datetime.now().isoformat() | ||
| await self.async_save() |
Comment on lines
+33
to
+37
| { | ||
| vol.Required(FIELD_NAME): cv.string, | ||
| vol.Required(FIELD_AMOUNT): vol.Coerce(float), | ||
| vol.Required(FIELD_DUE_DATE): cv.string, | ||
| vol.Optional(FIELD_NOTE, default=""): cv.string, |
| icon: mdi:calendar-clock | ||
| ``` | ||
|
|
||
| > Dokładne nazwy encji zależą od nazwy instancji integracji. Sprawdź je w **Ustawienia → Urządzenia i usługi → Opłaty**. |
| "domain": "oplats", | ||
| "name": "Opłaty", | ||
| "version": "1.0.0", | ||
| "codeowners": [], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a full Home Assistant custom integration for manually tracking bills/payments with paid/unpaid state, automatic transfer timestamp recording, and persistence across restarts.
Integration structure (
custom_components/oplats/)coordinator.py— Core data layer using HAStore(.storage/oplats_bills). Handles CRUD +mark_paid(setsdata_przelewu=now()) /mark_unpaid(clears it). Notifies sensor listeners on every mutation.__init__.py— Registers 5 HA services with Voluptuous schema validation:oplats.add_bill,oplats.update_bill,oplats.delete_billoplats.mark_paid,oplats.mark_unpaidsensor.py— Three aggregate sensors with live listener-based updates:Opłaty – Niezapłacone(unpaid count + list in attributes)Opłaty – Przeterminowane(overdue count — unpaid + past due date)Opłaty – Najbliższy termin(nearest upcoming due date)config_flow.py— Single-instance UI config flowservices.yaml— Polish-labeled field definitions with typed selectorstranslations/pl.json— Full PL translations for config flow and all servicesREADME.md— Install guide (manual + HACS), service call examples, Lovelace card YAMLExample service calls
Bill data (including paid status and transfer timestamps) survives HA restarts via
.storage.Original prompt