Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
260 commits
Select commit Hold shift + click to select a range
ffdbb9d
Remove obsolete error
andrew-codechimp Aug 1, 2025
5c6fa50
Add advanced settings to options schema and update translations
andrew-codechimp Aug 1, 2025
03eb4c5
Import config yaml
andrew-codechimp Aug 1, 2025
7230499
Raise issue on deprecated yaml
andrew-codechimp Aug 1, 2025
6430800
Reorder options below flow
andrew-codechimp Aug 1, 2025
ec4db44
Move discovery to setup_entry
andrew-codechimp Aug 1, 2025
7a551d5
Add subentry coordinators
andrew-codechimp Aug 1, 2025
725fa24
Hard code library & schema urls
andrew-codechimp Aug 1, 2025
6db3a18
Default migrate base entry
andrew-codechimp Aug 1, 2025
c1d7908
Add device sub entry
andrew-codechimp Aug 1, 2025
244e2fc
Temp remove device setup
andrew-codechimp Aug 1, 2025
d3b22d8
WIP
andrew-codechimp Aug 1, 2025
f29f8df
Add duplicate check on sub entries
andrew-codechimp Aug 1, 2025
f627317
Add sub entry reconfigure
andrew-codechimp Aug 1, 2025
92dc72a
Fix discovery add subentry
andrew-codechimp Aug 1, 2025
237e130
Add discovery strings
andrew-codechimp Aug 1, 2025
6b133aa
Remove unused discovery strings
andrew-codechimp Aug 1, 2025
2484b78
Comments
andrew-codechimp Aug 1, 2025
85ba27d
Work on reconfigure battery note
andrew-codechimp Aug 2, 2025
6c9cdeb
Fix template in reconfigure
andrew-codechimp Aug 2, 2025
09ab9d1
Discovery sub entry check
andrew-codechimp Aug 3, 2025
2a9450c
Tidy up old code within config_flow
andrew-codechimp Aug 3, 2025
39c1e51
WIP
andrew-codechimp Aug 3, 2025
bc3ae37
WIP
andrew-codechimp Aug 3, 2025
ff2db83
WIP
andrew-codechimp Aug 3, 2025
383dc37
WIP
andrew-codechimp Aug 4, 2025
a497982
WIP
andrew-codechimp Aug 4, 2025
fa9e4c9
WIP
andrew-codechimp Aug 4, 2025
14f676f
WIP
andrew-codechimp Aug 4, 2025
59fee12
WIP
andrew-codechimp Aug 4, 2025
53271fa
Temp old method to test sub entry
andrew-codechimp Aug 4, 2025
f20af33
Update Home Assistant version to 2025.8.0 in pyproject.toml and requi…
andrew-codechimp Aug 7, 2025
59adb82
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Aug 8, 2025
f3ba8a0
Refactor BatteryNotesTypeSensor class to remove SensorEntity inherita…
andrew-codechimp Aug 8, 2025
22c924b
Refactor BatteryNotesTypeSensor and add BatteryNotesLastReplacedSenso…
andrew-codechimp Aug 8, 2025
b12b0ae
Refactor BatteryNotesEntity and related classes for improved device a…
andrew-codechimp Aug 8, 2025
29a1041
Fix formatting of require_device parameter in async_setup_entry function
andrew-codechimp Aug 8, 2025
2e0f8b0
Refactor imports in __init__.py and sensor.py to streamline code and …
andrew-codechimp Aug 8, 2025
e0ca4e9
Refactor button.py and entity.py to remove unused imports and streaml…
andrew-codechimp Aug 8, 2025
7b45623
Refactor entity and sensor classes to improve entity ID setup and str…
andrew-codechimp Aug 10, 2025
3788018
Refactor button and sensor modules to streamline entity initializatio…
andrew-codechimp Aug 10, 2025
ee7362f
Refactor binary sensor, button, and sensor modules to improve entity …
andrew-codechimp Aug 10, 2025
5551e9b
Refactor battery notes integration to enhance type hinting, streamlin…
andrew-codechimp Aug 10, 2025
53abd8e
Refactor BatteryNotesData to enhance subentry handling and improve ru…
andrew-codechimp Aug 10, 2025
1caa504
Refactor binary sensor and button modules to remove unused imports an…
andrew-codechimp Aug 10, 2025
7a28038
Update entity options comment for legacy v1 support clarification
andrew-codechimp Aug 10, 2025
90ccef5
Refactor battery replaced and battery low service handlers to improve…
andrew-codechimp Aug 10, 2025
065f888
Clarify TODO comment for async_remove_entry in update_listener function
andrew-codechimp Aug 10, 2025
b59ea0e
Update default battery low threshold description for clarity
andrew-codechimp Aug 10, 2025
eb36666
Update configuration flow to use subentry title for name defaults and…
andrew-codechimp Aug 10, 2025
569836a
Add filtered battery sensor and enhance coordinator with unique ID an…
andrew-codechimp Aug 10, 2025
6d038c4
Add BINARY_SENSOR platform to supported platforms list
andrew-codechimp Aug 11, 2025
749334e
Merge branch 'main' into sub-devices
andrew-codechimp Aug 12, 2025
49969a4
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Aug 12, 2025
14ac034
Update poetry
andrew-codechimp Aug 12, 2025
f32f361
Remove fake device and filter outliers
andrew-codechimp Aug 12, 2025
9492a03
Support removing of sub entries
andrew-codechimp Aug 12, 2025
7c9e85d
Remove todo
andrew-codechimp Aug 12, 2025
d539808
Enhance subentry removal process in Battery Notes integration
andrew-codechimp Aug 12, 2025
d04f1a6
Remove unused imports from __init__.py
andrew-codechimp Aug 12, 2025
1b2de69
Create new config entry if old removed when we have discovered items
andrew-codechimp Aug 12, 2025
cfa534b
Remove unused code
andrew-codechimp Aug 12, 2025
9300007
Fix migration entry versioning in async_migrate_entry function
andrew-codechimp Aug 12, 2025
81510c9
Work on migration
andrew-codechimp Aug 12, 2025
14d68be
Remove unused variable in async_migrate_entry function
andrew-codechimp Aug 12, 2025
4ddc6df
Remove unused import of CONFIG_VERSION from __init__.py
andrew-codechimp Aug 12, 2025
9f3dd50
Refactor configuration handling in async_setup and async_migrate_entr…
andrew-codechimp Aug 12, 2025
b685817
Remove battery note from source device
andrew-codechimp Aug 12, 2025
6ab2ea1
Add missing newline for improved readability in async_migrate_entry f…
andrew-codechimp Aug 12, 2025
d7ed04f
Refactor variable names in async_migrate_entry for clarity
andrew-codechimp Aug 12, 2025
7da34a5
Rename BatteryNotesCoordinator to BatteryNotesSubentryCoordinator for…
andrew-codechimp Aug 13, 2025
899c762
Update missing device repair flow to include subentry_id handling
andrew-codechimp Aug 13, 2025
c79fb84
Add exception handling for unconfigured entities in Battery Notes
andrew-codechimp Aug 13, 2025
b097809
WIP
andrew-codechimp Aug 13, 2025
a0dee29
Migrate integration
andrew-codechimp Aug 13, 2025
fafb0d7
Refactor migration and update listener functions for clarity and cons…
andrew-codechimp Aug 13, 2025
704a068
Refactor subentry removal functions for consistency and clarity
andrew-codechimp Aug 13, 2025
205e5b1
Refactor integration migration code for improved readability and cons…
andrew-codechimp Aug 13, 2025
3cf6e6d
MyPy
andrew-codechimp Aug 13, 2025
486e8ad
Tidy
andrew-codechimp Aug 13, 2025
0a086ab
Refactor subentry type references to use constant for consistency
andrew-codechimp Aug 13, 2025
e904417
Allow discovery ignore
andrew-codechimp Aug 13, 2025
32d22ad
Add comprehensive AI coding instructions for Battery Notes integration
andrew-codechimp Aug 13, 2025
e92fe00
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Aug 13, 2025
fbc21f9
Fix subentry removal logic in Battery Notes integration
andrew-codechimp Aug 13, 2025
3dd93b6
Subentry check for orphaned battery notes
andrew-codechimp Aug 14, 2025
5e9d8eb
Refactor orphaned property to is_orphaned in coordinator and update r…
andrew-codechimp Aug 14, 2025
eb73a1c
Rename _link_device to _link_to_source for clarity and update related…
andrew-codechimp Aug 14, 2025
591b48a
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Aug 16, 2025
eb102ee
Delay discovery until HA fully started
andrew-codechimp Aug 16, 2025
cd4c34e
Moe library update to post HA start
andrew-codechimp Aug 16, 2025
1200d41
Remove obsolete code
andrew-codechimp Aug 17, 2025
d0f2dd0
mypy
andrew-codechimp Aug 17, 2025
77ccb6b
Add back from the future check
andrew-codechimp Aug 17, 2025
421f3d8
Skip ignored config entries
andrew-codechimp Aug 17, 2025
37f1e6c
Only migrate user entries
andrew-codechimp Aug 17, 2025
b394331
Filter entries by user source during migration and setup
andrew-codechimp Aug 17, 2025
41d3468
Refactor migration logic to simplify entry filtering by user source
andrew-codechimp Aug 17, 2025
1ecda17
Refactor migration logic to handle ignored config entries
andrew-codechimp Aug 17, 2025
ff514a1
Add default value for battery low template in coordinator
andrew-codechimp Aug 17, 2025
570815c
Set default values for battery type and quantity in coordinator
andrew-codechimp Aug 17, 2025
dd5ce47
Add TODO comment to tidy up entry data from discovery
andrew-codechimp Aug 17, 2025
efe3896
Add example data
andrew-codechimp Aug 17, 2025
f90aafc
Remove discovery data from config entry
andrew-codechimp Aug 18, 2025
2fbcb38
Remove manufacturer and model information from entry data in migratio…
andrew-codechimp Aug 18, 2025
aa56945
Fix config flow discovery
andrew-codechimp Aug 18, 2025
014b621
Update migration logic to exclude ignored entries from version check
andrew-codechimp Aug 18, 2025
cf617e2
Fix for library hw_version matching
andrew-codechimp Aug 18, 2025
1d2a462
Update v2 ignored entries
andrew-codechimp Aug 18, 2025
7b12051
Add new commented out test
andrew-codechimp Aug 18, 2025
fd453e7
Refactor device battery details retrieval to use constant for model_id
andrew-codechimp Aug 18, 2025
27435dd
Refactor migration logic to use MappingProxyType for entry data and i…
andrew-codechimp Aug 18, 2025
c1aad30
Fix unique ID generation for battery sensor entities in async_setup_e…
andrew-codechimp Aug 18, 2025
05717a1
Ignore disable entries on migration
andrew-codechimp Aug 18, 2025
bd634b2
Migrate entity unique id's
andrew-codechimp Aug 19, 2025
7cd16b8
Delete disabled config entries
andrew-codechimp Aug 20, 2025
802c151
Clean up accidental discovery data in migration process
andrew-codechimp Aug 20, 2025
8737c4e
Refactor unique ID check to include ignored and disabled entries in c…
andrew-codechimp Aug 20, 2025
3f412f5
Add assertion to ensure config entry is not None in BatteryNotesFlowH…
andrew-codechimp Aug 20, 2025
902f1f9
Fix config entry retrieval and enhance device matching logic in Batte…
andrew-codechimp Aug 21, 2025
b5ef188
Remove unused SOURCE_IGNORE import from config flow and discovery mod…
andrew-codechimp Aug 21, 2025
6ba545f
Fix discovery
andrew-codechimp Aug 22, 2025
784612e
Add better instructions
andrew-codechimp Aug 24, 2025
933faff
Device name attribute is now always the subentry title
andrew-codechimp Aug 24, 2025
8d2d48c
Reorder device name assignment logic to prioritize subentry title
andrew-codechimp Aug 24, 2025
afb9951
Enhance device name assignment logic to include user-defined names an…
andrew-codechimp Aug 24, 2025
029ac71
Refactor assertion syntax for improved readability
andrew-codechimp Aug 24, 2025
ed50d07
Add hardware version support and clean up imports in battery_notes in…
andrew-codechimp Aug 24, 2025
88818af
Update extensions
andrew-codechimp Aug 24, 2025
3d5b282
Remove unnecessary newline in battery note entry type definition
andrew-codechimp Aug 24, 2025
50938b8
Translations ar, ca
andrew-codechimp Aug 24, 2025
88148a1
Translate cs
andrew-codechimp Aug 24, 2025
adccd92
Translate da
andrew-codechimp Aug 24, 2025
9e3ff43
Translate de
andrew-codechimp Aug 24, 2025
b4902c9
Translate el
andrew-codechimp Aug 24, 2025
eeaae16
Translate pr-br, es-es
andrew-codechimp Aug 24, 2025
e1a4cf6
Transalte fi
andrew-codechimp Aug 24, 2025
423b668
Translate fr
andrew-codechimp Aug 24, 2025
8ed522a
Translate hu
andrew-codechimp Aug 24, 2025
3f2ec44
Translate it
andrew-codechimp Aug 24, 2025
d4c6a20
Translate lt
andrew-codechimp Aug 24, 2025
4b30d91
Translate lv
andrew-codechimp Aug 24, 2025
793842c
Translate zh-Hant
andrew-codechimp Aug 24, 2025
d5f9a02
Update en translation
andrew-codechimp Aug 24, 2025
7cc1ff6
Translate zh-Hans
andrew-codechimp Aug 24, 2025
7d921bd
Translate ur-IN
andrew-codechimp Aug 24, 2025
57cb94f
Translate uk
andrew-codechimp Aug 24, 2025
e4077ee
Translate remaining
andrew-codechimp Aug 24, 2025
ddf9f5c
Fix translations
andrew-codechimp Aug 24, 2025
cb2bc14
Refactor entity ID handling to ignore domain in BatteryNotesEntity
andrew-codechimp Aug 24, 2025
e0f118a
Suppress unused argument warnings in template event callbacks and sen…
andrew-codechimp Aug 24, 2025
b39ea22
Refactor template variable names for consistency in BatteryNotesBatte…
andrew-codechimp Aug 24, 2025
6a8d60f
Add wrapped_attributes to BatteryNotesBatteryBinaryLowSensor for stat…
andrew-codechimp Aug 24, 2025
02d9d33
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Aug 26, 2025
4093f07
Refactor integration entry retrieval in BatteryNotesFlowHandler
andrew-codechimp Aug 31, 2025
02cb2e7
Refactor integration entry retrieval to use async method in BatteryNo…
andrew-codechimp Aug 31, 2025
04ee6e5
Refactor timer_update method and improve logging format in LibraryUpd…
andrew-codechimp Aug 31, 2025
370b98f
Update translations to capitalize "Battery+" in data descriptions acr…
andrew-codechimp Aug 31, 2025
6605485
Fix variable name for battery type in async_migrate_entry function
andrew-codechimp Aug 31, 2025
0ec3bc7
Refactor variable names for battery quantity in async_migrate_entry f…
andrew-codechimp Aug 31, 2025
0905e01
Refactor async_setup_entry to simplify event listener management and …
andrew-codechimp Aug 31, 2025
f18b24f
Add debug log for existing battery_notes config entry during flow ini…
andrew-codechimp Aug 31, 2025
424aa83
Prevent second discovery
andrew-codechimp Sep 1, 2025
2f0ae39
Refactor async_setup_entry to improve discovery management and update…
andrew-codechimp Sep 1, 2025
46806ec
Remove unused import of EVENT_HOMEASSISTANT_STARTED and dt_util from …
andrew-codechimp Sep 1, 2025
f9e91a6
Update discovery.py to include SOURCE_IGNORE in config entry checks f…
andrew-codechimp Sep 1, 2025
a07720f
Set startup flag to True for library updates during entry setup
andrew-codechimp Sep 2, 2025
4f33f6a
Refactor async_get_config_entry_diagnostics to include subentry devic…
andrew-codechimp Sep 2, 2025
4ca8038
Bump to HA 2025.9
andrew-codechimp Sep 4, 2025
063b6ff
Merge branch 'sub-devices' into docs-v3
andrew-codechimp Sep 7, 2025
b6a3e1a
Update docs for v3
andrew-codechimp Sep 7, 2025
2298b58
Update bug report checklist for clarity on Home Assistant restart
andrew-codechimp Sep 7, 2025
a263838
Fix default value retrieval for CONF_BATTERY_LOW_THRESHOLD in config …
andrew-codechimp Sep 7, 2025
30fbf90
Update device info screenshot
andrew-codechimp Sep 7, 2025
0718585
Merge branch 'sub-devices' into docs-v3
andrew-codechimp Sep 7, 2025
ea2b55d
Increase discovery delay from 10 to 30 seconds for improved stability
andrew-codechimp Sep 7, 2025
730210d
Revert "Increase discovery delay from 10 to 30 seconds for improved s…
andrew-codechimp Sep 7, 2025
b47affa
Refactor device matching logic to simplify conditions and improve rea…
andrew-codechimp Sep 9, 2025
bbcadec
Add check to ensure only one matching device is returned in get_devic…
andrew-codechimp Sep 9, 2025
5297753
Refactor device matching methods to use consistent parameter naming f…
andrew-codechimp Sep 9, 2025
c206ac6
Refactor device matching logic to use exact matching and simplify cod…
andrew-codechimp Sep 9, 2025
6d41e39
Add type check for devices in Library to ensure they are dictionaries
andrew-codechimp Sep 9, 2025
f9ed544
Revert "Add type check for devices in Library to ensure they are dict…
andrew-codechimp Sep 10, 2025
4245ef4
Revert "Refactor device matching logic to use exact matching and simp…
andrew-codechimp Sep 10, 2025
664553a
Update Portuguese translations for battery notes integration
andrew-codechimp Sep 10, 2025
c931396
Add type check for matched device in get_device_battery_details method
andrew-codechimp Sep 10, 2025
cbae427
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Sep 10, 2025
b701233
Add some basic AI tests
andrew-codechimp Sep 10, 2025
c1df9f5
Revert "Add some basic AI tests"
andrew-codechimp Sep 10, 2025
3a42c26
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Sep 13, 2025
9e06975
Refactor device storage in Library class to use a dictionary keyed by…
andrew-codechimp Sep 13, 2025
9bbd53b
Refactor Library class to use LibraryDevice dataclass for improved de…
andrew-codechimp Sep 13, 2025
4670fe5
Remove unused DOMAIN_CONFIG constant from const.py
andrew-codechimp Sep 15, 2025
c93526d
Move library into Hass Data
andrew-codechimp Sep 15, 2025
3cdf34c
Fix no config entry on discovery add, plus fix removal
andrew-codechimp Sep 16, 2025
48945be
Merge branch 'sub-devices' into docs-v3
andrew-codechimp Sep 16, 2025
e334572
Update initial setup docs
andrew-codechimp Sep 16, 2025
67ed2a1
Add integration not added error message to config flow and translations
andrew-codechimp Sep 16, 2025
e3abb80
Fix timer_update method signature to include 'now' parameter
andrew-codechimp Sep 18, 2025
76d2744
Add include devices filter to battery not reported and threshold blue…
andrew-codechimp Sep 20, 2025
8a3043c
Refactor device inclusion logic in battery blueprints to simplify fil…
andrew-codechimp Sep 21, 2025
0cce93b
Remove entity restriction for included devices in battery blueprints
andrew-codechimp Sep 21, 2025
ecca84d
Remove unnecessary assertion for device name in BatteryNotesSubentryC…
andrew-codechimp Sep 22, 2025
01c4db3
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Sep 22, 2025
c0dcf2b
Update poetry
andrew-codechimp Sep 22, 2025
c50c010
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Sep 22, 2025
9b9b7d9
Add device inclusion filter to battery notes blueprints
andrew-codechimp Sep 23, 2025
71a85c9
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Sep 23, 2025
9551f09
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Sep 26, 2025
3cd47ee
Merge branch 'main' into sub-devices
andrew-codechimp Sep 26, 2025
bc0340f
Fix battery low rename
andrew-codechimp Oct 2, 2025
ce321a7
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Oct 7, 2025
2a91dd3
Add documentation URL placeholder to configuration steps
andrew-codechimp Oct 19, 2025
468b0ae
Add headers to library update
andrew-codechimp Oct 20, 2025
3becb57
Add Accept-Encoding header to library updater
andrew-codechimp Oct 22, 2025
d34ae1d
Set confirm_only context for user confirmation step in config flow
andrew-codechimp Oct 23, 2025
bbbadf4
Revert "Set confirm_only context for user confirmation step in config…
andrew-codechimp Oct 23, 2025
800d1ca
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Oct 27, 2025
59d2b1e
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Oct 28, 2025
bd96acb
Fix docstring and import ordering
andrew-codechimp Oct 30, 2025
6c3ac65
Reorder imports
andrew-codechimp Oct 30, 2025
24acfc4
Lint
andrew-codechimp Oct 30, 2025
82a7711
Formatting
andrew-codechimp Oct 30, 2025
4d901cf
Formatting
andrew-codechimp Oct 30, 2025
f94e6eb
Update gitignore
andrew-codechimp Oct 30, 2025
3a5efd5
Change import
andrew-codechimp Oct 30, 2025
df4992e
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Oct 31, 2025
1b5bc7e
Bump HA version
andrew-codechimp Oct 31, 2025
5832c6a
Update uv lock
andrew-codechimp Oct 31, 2025
661c7e6
lint fixes
andrew-codechimp Oct 31, 2025
6bcc24a
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Nov 2, 2025
b774f87
Bump HA version
andrew-codechimp Nov 2, 2025
e0d77bf
Enable ruff formatting
andrew-codechimp Nov 2, 2025
c65be4c
Ruff formatting
andrew-codechimp Nov 2, 2025
215ca68
Lint
andrew-codechimp Nov 2, 2025
768a7c1
Lint
andrew-codechimp Nov 2, 2025
2ce183a
Lint
andrew-codechimp Nov 2, 2025
36a400e
Lint
andrew-codechimp Nov 2, 2025
5d875f1
Lint
andrew-codechimp Nov 2, 2025
39880fa
Lint
andrew-codechimp Nov 2, 2025
a88f9fd
Lint
andrew-codechimp Nov 2, 2025
2b6c3ec
Lint
andrew-codechimp Nov 2, 2025
c67360c
Fix threshold blueprint
andrew-codechimp Nov 6, 2025
e991f8f
Update threshold blueprint
andrew-codechimp Nov 7, 2025
5449630
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Nov 7, 2025
e1e72ea
Update threshold blueprint
andrew-codechimp Nov 7, 2025
c3f5fd0
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Nov 7, 2025
a7dc9af
Add ignore rule for TC006 in ruff linting configuration
andrew-codechimp Nov 10, 2025
9985862
Merge remote-tracking branch 'origin/main' into sub-devices
andrew-codechimp Nov 11, 2025
e68f67b
Remove duplicate options section
andrew-codechimp Nov 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ body:
attributes:
label: Checklist
options:
- label: I have added `battery_notes:` to my configuration.yaml and restarted.
- label: I have restarted Home Assistant after the HACS or manual install.
required: true
- label: I have read the [FAQ's](https://andrew-codechimp.github.io/HA-Battery-Notes/faq).
required: true
Expand Down
140 changes: 140 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Battery Notes - AI Coding Instructions

## Project Overview
Battery Notes is a Home Assistant custom integration that tracks battery information for IoT devices. It uses a **sub-entry architecture** where a single config entry can manage multiple battery devices via ConfigSubentry objects.

## Architecture & Core Components

### Config Entry Structure (Critical)
- **Main Config Entry**: Domain-level configuration (`BatteryNotesConfigEntry`)
- **Sub-entries**: Individual device configurations (`ConfigSubentry`) stored in `config_entry.runtime_data.subentries`
- **Coordinators**: Each sub-entry has its own `BatteryNotesSubentryCoordinator` in `config_entry.runtime_data.subentry_coordinators[subentry_id]`

**Key Pattern**: Always iterate through `subentry_coordinators.values()` not the main coordinator when looking for devices.

### Entity Inheritance Structure
- `BatteryNotesEntity` (base class in `entity.py`) - handles device association and common setup
- Sensor classes inherit from both `BatteryNotesEntity` and HA sensor classes
- Example: `class BatteryNotesTypeSensor(BatteryNotesEntity, RestoreSensor)`

### Device Discovery & Library
- `library/library.json`: 10K+ device definitions with battery types
- `discovery.py`: Auto-discovers devices and creates config entries
- Device matching: `manufacturer` + `model` (+ optional `hw_version`)

## Key File Responsibilities

### Core Files
- `__init__.py`: Config entry setup, sub-entry management, platform loading
- `coordinator.py`: Data coordination, battery level tracking, event firing
- `config_flow.py`: UI configuration flows for manual device addition
- `services.py`: Battery replacement service handlers
- `entity.py`: Base entity class with device association logic

### Platform Files
- `sensor.py`: Battery type, battery+, and last replaced sensors
- `binary_sensor.py`: Battery low binary sensors
- `button.py`: Battery replaced action buttons

### Supporting Files
- `library.py`: Device library management and updates
- `discovery.py`: Automatic device discovery from library
- `const.py`: All constants, service schemas, event names
- `store.py`: Persistent storage for user data

## Development Workflow

### Local Development
```bash
# Start HA development server on port 8123
./scripts/develop

# Lint code
./scripts/lint

# Check types (if mypy installed)
mypy custom_components/battery_notes/ --check-untyped-defs
```

### File Structure Conventions
- Put constants in `const.py` with proper categorization
- Use dataclasses for configuration objects
- Service schemas defined in `const.py`, handlers in `services.py`
- All entities extend `BatteryNotesEntity` base class

## Critical Patterns

### Sub-entry Iteration Pattern
```python
# CORRECT - iterate through sub-entry coordinators
for config_entry in hass.config_entries.async_loaded_entries(DOMAIN):
if not config_entry.runtime_data.subentry_coordinators:
continue
for coordinator in config_entry.runtime_data.subentry_coordinators.values():
if coordinator.device_id == target_device_id:
# Process device
```

### Entity Registration Pattern
```python
# Use unique_id from coordinator + description suffix
self._attr_unique_id = f"{coordinator.device_id}_{description.unique_id_suffix}"

# Handle entity naming based on device association
if coordinator.source_entity_id and not coordinator.device_id:
self._attr_translation_placeholders = {"device_name": coordinator.device_name + " "}
```

### Service Implementation Pattern
```python
# Always validate device exists before processing
device_found = False
for coordinator in subentry_coordinators.values():
if coordinator.device_id == device_id:
device_found = True
# Process service call
break

if not device_found:
_LOGGER.error("Device %s not configured in Battery Notes", device_id)
return None
```

## Testing & Validation

### Type Checking
- Project uses mypy with `--check-untyped-defs`
- All major classes use type hints
- ConfigEntry typing: `BatteryNotesConfigEntry = ConfigEntry[BatteryNotesData]`

### Linting
- Uses `ruff` for code formatting and linting
- Config in `pyproject.toml`
- Run `./scripts/lint` before commits

## Integration Points

### Home Assistant APIs
- Device Registry: Link entities to HA devices
- Entity Registry: Manage entity lifecycle
- Event Bus: Fire battery events (`EVENT_BATTERY_THRESHOLD`, `EVENT_BATTERY_REPLACED`)
- Config Flow: Handle UI configuration

### External Dependencies
- Library updates from `https://battery-notes-data.codechimp.org/library.json`
- Version checking with `awesomeversion`
- Data validation with `voluptuous`

## Common Tasks

### Adding New Entity Types
1. Create entity description in appropriate platform file
2. Extend `BatteryNotesEntity` base class
3. Add to platform's `async_setup_entry` function
4. Register constants in `const.py`

### Adding New Services
1. Define schema in `const.py`
2. Implement handler in `services.py` using sub-entry iteration pattern
3. Register in `__init__.py` `async_setup_entry`
4. Add service definition to `services.yaml`
9 changes: 4 additions & 5 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
with:
args: check --output-format=github

#TODO: Temporary disable until V3
# - name: Ruff Format
# uses: astral-sh/ruff-action@v3
# with:
# args: format --check --diff
- name: Ruff Format
uses: astral-sh/ruff-action@v3
with:
args: format --check --diff
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ config/*
!config/configuration.yaml
.DS_Store
config/configuration.yaml

backup/*
custom_components/battery_notes/frontend/node_modules
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,29 @@ _If you want to show your support please_

## Installation

**Important**

Once you have installed battery notes using either HACS or manually as per the instructions below you must add the following entry to your `configuration.yaml`, then restart Home Assistant. This will enable discovery of your devices.

```
battery_notes:
```

If you need to add a device that is not automatically discovered from the library go to Settings -> Integrations click "+" and search for "Battery Notes"

### HACS Installation

[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=andrew-codechimp&repository=HA-Battery-Notes&category=Integration)

Or
Search for `Battery Notes` in HACS and install it under the "Integrations" category.

Restart Home Assistant

In the HA UI go to Settings -> Integrations click "+ Add integration" and search for "Battery Notes"

This will create the main Battery Notes integration service and discovery will start shortly afterwards, or you can battery notes manually within the integration.

### Manual Installation

<details>
<summary>More Details</summary>

- You should take the battery_notes.zip file from the latest [published release](https://github.com/andrew-codechimp/ha-battery-notes/releases).
- To install, place the contents of `custom_components` into the `<config directory>/custom_components` folder of your Home Assistant installation.
- Add the following entry to your `configuration.yaml`

```
battery_notes:
```

- Restart Home Assistant
- In the HA UI go to Settings -> Integrations click "+" and search for "Battery Notes"
- In the HA UI go to Settings -> Integrations click "+ Add integration" and search for "Battery Notes"
- This will create the main Battery Notes integration service and discovery will start shortly afterwards, or you can battery notes manually within the integration.
</details>

## Docs
Expand Down
Loading
Loading