Skip to content

Commit bdcdd58

Browse files
Add device name to battery+ attributes
1 parent 154c973 commit bdcdd58

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

custom_components/battery_notes/sensor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
ATTR_BATTERY_LAST_REPORTED,
7070
ATTR_BATTERY_LAST_REPORTED_LEVEL,
7171
ATTR_DEVICE_ID,
72+
ATTR_DEVICE_NAME,
7273
)
7374

7475
from .common import isfloat
@@ -492,6 +493,7 @@ def extra_state_attributes(self) -> dict[str, str] | None:
492493

493494
# Other attributes that should follow battery, attribute list is unsorted
494495
attrs[ATTR_DEVICE_ID] = self.coordinator.device_id
496+
attrs[ATTR_DEVICE_NAME] = self.coordinator.device_name
495497

496498
super_attrs = super().extra_state_attributes
497499
if super_attrs:

docs/entities.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ See how to use this entity in the [community contributions](./community.md)
2222
| `battery_last_reported` | `datetime` | The datetime when the battery level was last reported |
2323
| `battery_last_reported_level` | `float` | The level when the battery was last reported |
2424
| `device_id` | `string` | The device_id of the device |
25+
| `device_name` | `string` | The name of the device |
2526

2627
## Battery Type
2728
`sensor.{{device_name}}_battery_type`

0 commit comments

Comments
 (0)