Checklist
Battery Notes Version
v3.4.3
Describe the issue
After updating to HA Core 2026.4, all sensor.*_battery_last_replaced entities
crash during setup with:
ValueError: Invalid datetime: sensor.XXX_battery_last_replaced provides state
'2024-08-31 13:27:15.201230', which is missing timezone information
Impact: The error causes the coordinator update to fail, which makes ALL
battery_notes entities unavailable — not just the _last_replaced sensors but
also _battery_plus, _battery_plus_low, and _battery_type entities.
Effectively, the entire integration is broken.
This happens because coordinator.py returns naive datetimes (without timezone)
from the last_replaced and last_reported property getters. HA Core 2026.4
strictly enforces timezone-aware datetimes for SensorDeviceClass.TIMESTAMP.
Important: This also happens after a complete clean reinstall of battery_notes
(remove integration + all entities via HACS, reinstall, re-add all devices).
The naive timestamps come from device_entry.created_at which is used as the
default for last_replaced in coordinator.py __init__.
Root Cause: In coordinator.py, the last_replaced property getter returns
a naive datetime via datetime.fromisoformat(str(entry[LAST_REPLACED])) when the
stored value has no timezone suffix. The setter stores device_entry.created_at
without ensuring timezone awareness. The store migration (_fix_datetime_string)
only fixes the colon/period issue from pre-3.3.2, not missing timezones.
Same issue affects last_reported.
Proposed Fix: A minimal helper ensuring UTC on all datetime reads and writes:
def _ensure_utc(dt_val):
if dt_val.tzinfo is None:
return dt_val.replace(tzinfo=datetime.timezone.utc)
return dt_val
Applied in coordinator.py to last_replaced and last_reported getters/setters.
Tested locally — resolves the issue completely. I can submit a PR if desired.
Related: #4595 fixed set_battery_replaced action but not this init path.
Reproduction steps
- Update to HA Core 2026.4+
- Install battery_notes v3.4.3 via HACS
- Add any device with a battery (or have existing devices)
- Restart HA
- Check Settings → System → Logs for "missing timezone information" errors
- Observe that all sensor.*_battery_last_replaced entities are unavailable
System Health details
System Information
| version |
core-2026.4.2 |
| installation_type |
Home Assistant OS |
| dev |
false |
| hassio |
true |
| docker |
true |
| container_arch |
amd64 |
| user |
root |
| virtualenv |
false |
| python_version |
3.14.2 |
| os_name |
Linux |
| os_version |
6.12.77-haos |
| arch |
x86_64 |
| timezone |
Europe/Vienna |
| config_dir |
/config |
Home Assistant Community Store
| GitHub API |
ok |
| GitHub Content |
ok |
| GitHub Web |
ok |
| HACS Data |
ok |
| GitHub API Calls Remaining |
4989 |
| Installed Version |
2.0.5 |
| Stage |
running |
| Available Repositories |
2938 |
| Downloaded Repositories |
75 |
Home Assistant Cloud
| logged_in |
true |
| subscription_expiration |
22. September 2026 um 02:00 |
| relayer_connected |
true |
| relayer_region |
eu-central-1 |
| remote_enabled |
true |
| remote_connected |
true |
| alexa_enabled |
false |
| google_enabled |
true |
| cloud_ice_servers_enabled |
true |
| remote_server |
eu-central-1-13.ui.nabu.casa |
| certificate_status |
ready |
| instance_id |
8559d840d5474c2ab1a66243384b65b0 |
| can_reach_cert_server |
ok |
| can_reach_cloud_auth |
ok |
| can_reach_cloud |
ok |
Home Assistant Supervisor
| host_os |
Home Assistant OS 17.2 |
| update_channel |
stable |
| supervisor_version |
supervisor-2026.04.0 |
| agent_version |
1.8.1 |
| docker_version |
29.3.1 |
| disk_total |
125.3 GB |
| disk_used |
26.6 GB |
| nameservers |
10.0.0.101, 10.0.0.100 |
| healthy |
true |
| supported |
true |
| host_connectivity |
true |
| supervisor_connectivity |
true |
| ntp_synchronized |
true |
| virtualization |
kvm |
| board |
ova |
| supervisor_api |
ok |
| version_api |
ok |
| installed_addons |
Advanced SSH & Web Terminal (23.0.6), ESPHome Device Builder (2026.3.3), File editor (6.0.0), PS5 MQTT (1.4.0), Mosquitto broker (6.5.2), Studio Code Server (6.0.1), Music Assistant (2.7.8), HA Vibecode Agent (2.10.40), Home Assistant Time Machine (2.3.1) |
Dashboards
| dashboards |
15 |
| resources |
46 |
| views |
46 |
| mode |
storage |
Network Configuration
| adapters |
lo (disabled), enp6s18 (enabled, default, auto), docker0 (disabled), hassio (disabled), veth0620562 (disabled), veth77a9a03 (disabled), vethefb9b7d (disabled), veth24fdb69 (disabled), veth4879bf5 (disabled), vethb0689c7 (disabled), veth7ed418a (disabled), veth6a64c71 (disabled), veth2be522f (disabled), veth6530e40 (disabled), veth2d64dc2 (disabled) |
| ipv4_addresses |
lo (127.0.0.1/8), enp6s18 (10.0.0.116/24), docker0 (172.30.232.1/23), hassio (172.30.32.1/23), veth0620562 (), veth77a9a03 (), vethefb9b7d (), veth24fdb69 (), veth4879bf5 (), vethb0689c7 (), veth7ed418a (), veth6a64c71 (), veth2be522f (), veth6530e40 (), veth2d64dc2 () |
| ipv6_addresses |
lo (::1/128), enp6s18 (fe80::2eec:17a4:6014:e461/64), docker0 (fe80::c8bf:c5ff:feef:f71d/64), hassio (fd0c:ac1e:2100::1/48, fe80::8cde:eff:fe64:da4b/64), veth0620562 (fe80::60c6:6eff:fe7b:9ae3/64), veth77a9a03 (fe80::4043:6fff:fe23:664e/64), vethefb9b7d (fe80::2070:89ff:fe13:5044/64), veth24fdb69 (fe80::c830:e3ff:fe9c:b51f/64), veth4879bf5 (fe80::9475:43ff:fe27:f948/64), vethb0689c7 (fe80::6406:24ff:fec4:5d90/64), veth7ed418a (fe80::aca0:ff:fe60:1d6f/64), veth6a64c71 (fe80::cc2:98ff:fe6e:5b3d/64), veth2be522f (fe80::68ec:30ff:fef1:fbb4/64), veth6530e40 (fe80::906e:35ff:fe9a:c1b6/64), veth2d64dc2 (fe80::3cb9:8aff:feee:7763/64) |
| announce_addresses |
10.0.0.116, fe80::2eec:17a4:6014:e461 |
Recorder
| oldest_recorder_run |
8. März 2026 um 14:16 |
| current_recorder_run |
15. April 2026 um 11:26 |
| estimated_db_size |
3209.72 MiB |
| database_engine |
sqlite |
| database_version |
3.49.2 |
Debug logs
2026-04-15 11:02:25.590 ERROR (MainThread) [homeassistant.components.sensor]
Error adding entity sensor.wasser_hobbyraum_battery_last_replaced for domain
sensor with platform battery_notes
Traceback (most recent call last):
File ".../entity_platform.py", line 680, in _async_add_entities
...
File ".../sensor/__init__.py", line 622, in state
raise ValueError(...)
ValueError: Invalid datetime: sensor.wasser_hobbyraum_battery_last_replaced
provides state '2024-08-31 13:27:15.201230', which is missing timezone information
Diagnostics dump
Diagnostics download not available for this integration.
Checklist
Battery Notes Version
v3.4.3
Describe the issue
After updating to HA Core 2026.4, all
sensor.*_battery_last_replacedentitiescrash during setup with:
ValueError: Invalid datetime: sensor.XXX_battery_last_replaced provides state
'2024-08-31 13:27:15.201230', which is missing timezone information
Impact: The error causes the coordinator update to fail, which makes ALL
battery_notes entities unavailable — not just the
_last_replacedsensors butalso
_battery_plus,_battery_plus_low, and_battery_typeentities.Effectively, the entire integration is broken.
This happens because
coordinator.pyreturns naive datetimes (without timezone)from the
last_replacedandlast_reportedproperty getters. HA Core 2026.4strictly enforces timezone-aware datetimes for
SensorDeviceClass.TIMESTAMP.Important: This also happens after a complete clean reinstall of battery_notes
(remove integration + all entities via HACS, reinstall, re-add all devices).
The naive timestamps come from
device_entry.created_atwhich is used as thedefault for
last_replacedincoordinator.py __init__.Root Cause: In
coordinator.py, thelast_replacedproperty getter returnsa naive datetime via
datetime.fromisoformat(str(entry[LAST_REPLACED]))when thestored value has no timezone suffix. The setter stores
device_entry.created_atwithout ensuring timezone awareness. The store migration (
_fix_datetime_string)only fixes the colon/period issue from pre-3.3.2, not missing timezones.
Same issue affects
last_reported.Proposed Fix: A minimal helper ensuring UTC on all datetime reads and writes:
Applied in
coordinator.pytolast_replacedandlast_reportedgetters/setters.Tested locally — resolves the issue completely. I can submit a PR if desired.
Related: #4595 fixed
set_battery_replacedaction but not this init path.Reproduction steps
System Health details
System Information
Home Assistant Community Store
Home Assistant Cloud
Home Assistant Supervisor
Dashboards
Network Configuration
Recorder
Debug logs
Diagnostics dump
Diagnostics download not available for this integration.