v1.1.5
HA 2026.5 compatibility fix (#228)
Affected users: Anyone running Home Assistant 2026.5 beta or later. Symptoms in the log:
Failed to set up sensor platform, error: cannot import name 'is_number' from 'homeassistant.helpers.template'
Detected blocking call to import_module with args ('custom_components.dynamic_energy_cost.sensor',) inside the event loop
The integration would fail to set up entirely — no real-time / hourly / daily / weekly / monthly cost sensors would be created.
Root cause
HA 2026.5 (PR #167280) refactored the template helpers and relocated is_number from homeassistant.helpers.template into a Jinja2 extension class (template.extensions.type_cast.TypeCastExtension). The public import path was removed.
Our sensor.py had from homeassistant.helpers.template import is_number for the calibrate service input validation. On 2026.5 that line raised ImportError, which prevented the sensor module from loading. The partially-initialised module was left in sys.modules, which then tripped HA 2026.5's stricter blocking-call detection on the import retry — that's the second error in the log. Both errors share the same root cause; fixing the import resolves both.
Fix
Replaced the removed import with a local _is_finite_number helper that mirrors the original behaviour (rejects inf/nan and unparseable values). No external dependency on the relocated function.
Added a regression test that asserts the offending import line is absent from sensor.py, so it cannot be reintroduced.
Compatibility
- ✅ HA 2026.4.x and earlier — works exactly as before
- ✅ HA 2026.5 (beta and stable) — integration loads cleanly
- ✅ All existing functionality (real-time, daily/weekly/monthly cost sensors,
calibrateservice,reset_costservice) unchanged
Other 2026.5 changes audited
We also reviewed the rest of HA 2026.5's developer changes against our code:
Entity.async_write_ha_statemarked final → we only call it, never override ✓- Entity ID mismatched domain deprecation → we register sensors as
sensor.✓ - Other template extension refactors (math, serialization, functional, version, entity, config_entry) → not used by us ✓
async_forward_entry_setupspattern → standard, fine onceis_numberresolves ✓
Upgrading
Update via HACS and restart Home Assistant. No configuration changes needed.
Full changelog: v1.1.4...v1.1.5