Skip to content

Commit

Permalink
Fix duplicated resource issue in System Monitor (#107671)
Browse files Browse the repository at this point in the history
* Fix duplicated resource issue

* Only slug the argument
  • Loading branch information
gjohansson-ST committed Jan 12, 2024
1 parent 83fbcb1 commit e715d6a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions homeassistant/components/systemmonitor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ async def async_setup_entry(
is_enabled = check_legacy_resource(
f"{_type}_{argument}", legacy_resources
)
loaded_resources.add(f"{_type}_{argument}")
loaded_resources.add(f"{_type}_{slugify(argument)}")
entities.append(
SystemMonitorSensor(
sensor_registry,
Expand All @@ -425,7 +425,7 @@ async def async_setup_entry(
is_enabled = check_legacy_resource(
f"{_type}_{argument}", legacy_resources
)
loaded_resources.add(f"{_type}_{argument}")
loaded_resources.add(f"{_type}_{slugify(argument)}")
entities.append(
SystemMonitorSensor(
sensor_registry,
Expand All @@ -449,7 +449,7 @@ async def async_setup_entry(
sensor_registry[(_type, argument)] = SensorData(
argument, None, None, None, None
)
loaded_resources.add(f"{_type}_{argument}")
loaded_resources.add(f"{_type}_{slugify(argument)}")
entities.append(
SystemMonitorSensor(
sensor_registry,
Expand Down Expand Up @@ -478,10 +478,13 @@ async def async_setup_entry(
# of mount points automatically discovered
for resource in legacy_resources:
if resource.startswith("disk_"):
check_resource = slugify(resource)
_LOGGER.debug(
"Check resource %s already loaded in %s", resource, loaded_resources
"Check resource %s already loaded in %s",
check_resource,
loaded_resources,
)
if resource not in loaded_resources:
if check_resource not in loaded_resources:
split_index = resource.rfind("_")
_type = resource[:split_index]
argument = resource[split_index + 1 :]
Expand Down

0 comments on commit e715d6a

Please sign in to comment.