Native Entity Aliasing for Home Assistant — Hardware-independent logical entities for the entire smart home #3402
Unanswered
Popoboxxo
asked this question in
Experimental ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe your idea
The Core Idea
Every device in a smart home has two identities: its physical identity (the hardware, the integration, the entity ID that HA assigns) and its logical identity (what it means in your home — the kitchen fridge, the living room light, the front door).
Today, Home Assistant only knows the physical identity. The moment you swap hardware, rename an integration, or migrate from one protocol to another, every automation, dashboard, utility meter, and the Energy Dashboard that referenced that entity breaks. Years of configuration need to be manually updated.
My proposal: Native Entity Aliasing — a first-class concept in Home Assistant where you define a stable logical entity that sits in front of any hardware entity. The logical entity never changes. The hardware behind it can change freely.
The Problem, Illustrated
You set up your living room light:
You build 12 automations, 3 dashboard cards, 2 scenes around it. Two years later you migrate from Hue to WLED. HA assigns:
Everything breaks. Not because your home changed — the light is still in the same corner of the same room. But because Home Assistant has no concept of "the living room main light" as a stable identity separate from the hardware that implements it.
This problem exists across every domain:
light.hue_color_candle_1light.living_room_mainclimate.myVAILLANT_zone_1climate.bedroomswitch.shelly_plus_plug_s_5a3c2bswitch.kitchen_fridgesensor.shelly_plus_plug_s_5a3c2b_energysensor.kitchen_fridge_total_energybinary_sensor.zigbee_door_contact_3a2fbinary_sensor.front_doorcover.somfy_rts_1cover.living_room_blindsThe logical entity is what your home means. The hardware entity is just the current implementation.
My Current Solution — Proof of Concept for Energy Sensors
I've been solving this manually for energy and power monitoring for over a year. I built a full Energy & Power Abstraction Layer in YAML that proves the concept works — but also shows exactly why it needs to be native.
Every physical smart plug in my setup gets exactly two template sensors that act as its stable logical interface. Nothing downstream — no dashboard, no utility meter, no automation, no Energy Dashboard entry — ever sees the raw hardware entity.
When I replace the Shelly with a Zigbee plug, I change one line. Every utility meter, Energy Dashboard entry, automation, and dashboard card continues to work without any modification.
The Bonus Problem: Spike-Proof Energy Monitoring
While running this pattern I discovered a second problem that the abstraction layer elegantly solves: some hardware energy sensors report wrong values.
Certain Zigbee and Tasmota plugs occasionally send a cumulative kWh value lower than the previous reading — a hardware glitch or reset.
utility_meterhas no defense: it counts every upward jump as real consumption and ignores downward corrections. Over time, phantom energy accumulates silently.The physical reality: a cumulative energy counter can only increase. So I built a monotonic guard into the template sensor using
this.state— the sensor's own previous rendered value:It works perfectly. But this is complex Jinja2 that encodes a simple physical law — it should never need to exist in user config.
The Vision — What Native Entity Aliasing Could Look Like
Taking the energy pattern and generalizing it to all of Home Assistant:
Or even better — directly in the Entity Registry UI:
The source changes. The alias stays. Everything downstream is unaffected.
Why is this exciting?
Hardware independence is one of HA's core promises — but right now, the moment you swap a device, you're manually hunting through automations, dashboards, utility meters, and the Energy Dashboard to update references. The more mature your setup, the more painful every hardware migration becomes. Power users with hundreds of entities are essentially locked into their hardware choices.
The Adapter Pattern — putting a stable interface in front of an unstable implementation — is one of the most proven concepts in software engineering. Industrial automation systems call this a "virtual sensor" or "process data object": the control logic never talks to physical hardware directly, always through a normalized data layer. Home Assistant users are rebuilding this manually, in Jinja2 and template sensors, in every installation. That's a signal it belongs in the core.
The monotonic guard for energy sensors is particularly exciting because it encodes physical reality into the data pipeline. Electricity consumption is monotonically increasing by definition. Building that constraint natively into
utility_meteror an alias platform would silently fix a class of phantom consumption bugs that many users don't even know they have.And beyond the technical: a logical entity layer makes Home Assistant dramatically more approachable for new users. Instead of
sensor.shelly_plus_plug_s_5a3c2b_energyappearing in automations and dashboards, they seesensor.kitchen_fridge_total_energy. The configuration becomes readable. The home becomes self-documenting.Potential use cases
total_increasingsensors silently protects against a widespread hardware bug classAnything else?
I've been running the energy abstraction pattern across ~100 devices for over 2 years.

The
this.statemonotonic trick is, as far as I know, largely undocumented in official HA docs. It exploits the fact that Jinja2 template sensors can reference their own last rendered state — enabling stateful filtering without helpers or automations. It works, but it's the kind of clever hack that signals a missing native feature.Note: I used AI (Claude) to help structure and articulate this discussion post. The underlying concept, the YAML implementation, and the year of real-world experience running it are entirely my own — the AI helped me turn a complex personal architecture decision into a readable proposal.
Beta Was this translation helpful? Give feedback.
All reactions