mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 08:26:41 +01:00
Stop manually assigning an entity_id in waterfurnace sensors (#165954)
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
ENTITY_ID_FORMAT,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
@@ -19,7 +18,6 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.util import slugify
|
||||
|
||||
from . import DOMAIN, WaterFurnaceConfigEntry
|
||||
from .coordinator import WaterFurnaceCoordinator
|
||||
@@ -178,10 +176,6 @@ class WaterFurnaceSensor(CoordinatorEntity[WaterFurnaceCoordinator], SensorEntit
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
|
||||
# This ensures that the sensors are isolated per waterfurnace unit
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(
|
||||
f"wf_{slugify(coordinator.unit)}_{slugify(description.key)}"
|
||||
)
|
||||
self._attr_unique_id = f"{coordinator.unit}_{description.key}"
|
||||
|
||||
device_info = DeviceInfo(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@ async def test_sensor(
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test states of the sensor."""
|
||||
state = hass.states.get("sensor.wf_test_gwid_12345_totalunitpower")
|
||||
state = hass.states.get("sensor.test_abc_type_total_power")
|
||||
assert state
|
||||
assert state.state == "1500"
|
||||
|
||||
@@ -45,7 +45,7 @@ async def test_sensor(
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.wf_test_gwid_12345_totalunitpower")
|
||||
state = hass.states.get("sensor.test_abc_type_total_power")
|
||||
assert state
|
||||
assert state.state == "2000"
|
||||
|
||||
@@ -65,7 +65,7 @@ async def test_availability(
|
||||
side_effect: Exception,
|
||||
) -> None:
|
||||
"""Ensure that we mark the entities unavailable correctly when service is offline."""
|
||||
entity_id = "sensor.wf_test_gwid_12345_totalunitpower"
|
||||
entity_id = "sensor.test_abc_type_total_power"
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
|
||||
Reference in New Issue
Block a user