mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Remove hardcoded entity_id from DSMR Reader sensors (#190685)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
ffaf0e9877
commit
e5d5a1d529
@@ -37,7 +37,6 @@ class DSMRSensor(SensorEntity):
|
||||
self.entity_description = description
|
||||
|
||||
slug = slugify(description.key.replace("/", "_"))
|
||||
self.entity_id = f"sensor.{slug}"
|
||||
self._attr_unique_id = f"{config_entry.entry_id}-{slug}"
|
||||
self._config_entry_id = config_entry.entry_id
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ async def test_entity_tariff(hass: HomeAssistant) -> None:
|
||||
async_fire_mqtt_message(hass, "dsmr/meter-stats/electricity_tariff", "")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
electricity_tariff = "sensor.dsmr_meter_stats_electricity_tariff"
|
||||
electricity_tariff = "sensor.electricity_tariff"
|
||||
assert hass.states.get(electricity_tariff).state == STATE_UNKNOWN
|
||||
|
||||
# Test high tariff
|
||||
@@ -86,7 +86,7 @@ async def test_entity_dsmr_transform(hass: HomeAssistant) -> None:
|
||||
async_fire_mqtt_message(hass, "dsmr/meter-stats/dsmr_version", "42")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
dsmr_version = "sensor.dsmr_meter_stats_dsmr_version"
|
||||
dsmr_version = "sensor.dsmr_version"
|
||||
assert hass.states.get(dsmr_version).state == "4.2"
|
||||
|
||||
# Test dsmr version, if it's not a digit
|
||||
|
||||
@@ -33,10 +33,10 @@ async def test_dsmr_sensor_mqtt(
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
electricity_delivered_1 = "sensor.dsmr_reading_electricity_delivered_1"
|
||||
electricity_delivered_1 = "sensor.low_tariff_usage"
|
||||
assert hass.states.get(electricity_delivered_1).state == STATE_UNKNOWN
|
||||
|
||||
electricity_delivered_2 = "sensor.dsmr_reading_electricity_delivered_2"
|
||||
electricity_delivered_2 = "sensor.high_tariff_usage"
|
||||
assert hass.states.get(electricity_delivered_2).state == STATE_UNKNOWN
|
||||
|
||||
# Test if the payload is empty
|
||||
|
||||
Reference in New Issue
Block a user