Skip to content

Commit 13daf44

Browse files
author
fwmone
committed
## [0.1.5] - 2026-03-01
### Added - Added long-term statistics support for battery-related sensors. - Battery voltage and battery percentage sensors are now marked as measurement sensors, enabling Home Assistant long-term statistics and historical trends. - Added `battery_percent_rechargeable` sensor to provide a more realistic battery level estimation when using rechargeable batteries (e.g. NiMH). ### Changed - Improved battery sensor metadata to align with Home Assistant best practices for long-term statistics (state class and measurement semantics). - Clarified separation between vendor-style battery percentage and rechargeable battery estimation.
1 parent 2256149 commit 13daf44

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/).
77

8+
## [0.1.5] - 2026-03-01
9+
10+
### Added
11+
- Added long-term statistics support for battery-related sensors.
12+
- Battery voltage and battery percentage sensors are now marked as measurement
13+
sensors, enabling Home Assistant long-term statistics and historical trends.
14+
- Added `battery_percent_rechargeable` sensor to provide a more realistic battery
15+
level estimation when using rechargeable batteries (e.g. NiMH).
16+
17+
### Changed
18+
- Improved battery sensor metadata to align with Home Assistant best practices
19+
for long-term statistics (state class and measurement semantics).
20+
- Clarified separation between vendor-style battery percentage and
21+
rechargeable battery estimation.
22+
823
## [0.1.4] - 2026-02-17
924

1025
### Added

custom_components/paperlesspaper_push/device_sensors.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from datetime import datetime, timezone
55
from typing import Any, Callable, Optional
66

7-
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass
7+
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass, SensorStateClass
88
from homeassistant.const import PERCENTAGE, UnitOfElectricPotential
99
from homeassistant.helpers.update_coordinator import CoordinatorEntity
1010
from homeassistant.helpers.entity import Entity
@@ -85,6 +85,8 @@ class _SensorDef:
8585
name: str
8686
device_class: SensorDeviceClass | None = None
8787
unit: str | None = None
88+
state_class: SensorStateClass | None = None
89+
suggested_display_precision: int | None = None
8890
value_fn: Callable[[dict], Any] = lambda d: None
8991

9092

@@ -94,20 +96,26 @@ class _SensorDef:
9496
name="Battery Voltage",
9597
device_class=SensorDeviceClass.VOLTAGE,
9698
unit=UnitOfElectricPotential.VOLT,
99+
state_class=SensorStateClass.MEASUREMENT,
100+
suggested_display_precision=2,
97101
value_fn=lambda d: _battery_voltage_v(_get_bat_mv(d)),
98102
),
99103
_SensorDef(
100104
key="battery_percent",
101105
name="Battery",
102106
device_class=SensorDeviceClass.BATTERY,
103107
unit=PERCENTAGE,
108+
state_class=SensorStateClass.MEASUREMENT,
109+
suggested_display_precision=0,
104110
value_fn=lambda d: _battery_percent_from_mv(_get_bat_mv(d)),
105111
),
106112
_SensorDef(
107113
key="battery_percent_rechargeable",
108114
name="Battery (Rechargeable)",
109115
device_class=SensorDeviceClass.BATTERY,
110116
unit=PERCENTAGE,
117+
state_class=SensorStateClass.MEASUREMENT,
118+
suggested_display_precision=0,
111119
value_fn=lambda d: _battery_percent_nimh(_get_bat_mv(d)),
112120
),
113121
_SensorDef(
@@ -147,6 +155,13 @@ def __init__(self, coordinator, sensor_def: _SensorDef, unique_prefix: str):
147155
self._attr_name = sensor_def.name
148156
self._attr_device_class = sensor_def.device_class
149157
self._attr_native_unit_of_measurement = sensor_def.unit
158+
159+
if sensor_def.state_class:
160+
self._attr_state_class = sensor_def.state_class
161+
162+
if sensor_def.suggested_display_precision is not None:
163+
self._attr_suggested_display_precision = sensor_def.suggested_display_precision
164+
150165
self._attr_suggested_object_id = f"{DOMAIN}_{sensor_def.key}"
151166

152167
@property

custom_components/paperlesspaper_push/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"domain": "paperlesspaper_push",
33
"name": "paperlesspaper Push",
4-
"version": "0.1.4",
4+
"version": "0.1.5",
55
"documentation": "https://github.com/fwmone/paperlesspaper_push",
66
"issue_tracker": "https://github.com/fwmone/paperlesspaper_push/issues",
77
"requirements": [],

0 commit comments

Comments
 (0)