Skip to content

Commit

Permalink
Add device name to battery+ attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codechimp committed Mar 13, 2024
1 parent 154c973 commit bdcdd58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom_components/battery_notes/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
ATTR_BATTERY_LAST_REPORTED,
ATTR_BATTERY_LAST_REPORTED_LEVEL,
ATTR_DEVICE_ID,
ATTR_DEVICE_NAME,
)

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

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

super_attrs = super().extra_state_attributes
if super_attrs:
Expand Down
1 change: 1 addition & 0 deletions docs/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ See how to use this entity in the [community contributions](./community.md)
| `battery_last_reported` | `datetime` | The datetime when the battery level was last reported |
| `battery_last_reported_level` | `float` | The level when the battery was last reported |
| `device_id` | `string` | The device_id of the device |
| `device_name` | `string` | The name of the device |

## Battery Type
`sensor.{{device_name}}_battery_type`
Expand Down

0 comments on commit bdcdd58

Please sign in to comment.