mirror of
https://github.com/home-assistant/core.git
synced 2025-05-15 11:29:15 +00:00
Fix duplicated resource issue in System Monitor (#107671)
* Fix duplicated resource issue * Only slug the argument
This commit is contained in:
parent
83fbcb11ea
commit
e715d6a7a1
@ -405,7 +405,7 @@ async def async_setup_entry(
|
|||||||
is_enabled = check_legacy_resource(
|
is_enabled = check_legacy_resource(
|
||||||
f"{_type}_{argument}", legacy_resources
|
f"{_type}_{argument}", legacy_resources
|
||||||
)
|
)
|
||||||
loaded_resources.add(f"{_type}_{argument}")
|
loaded_resources.add(f"{_type}_{slugify(argument)}")
|
||||||
entities.append(
|
entities.append(
|
||||||
SystemMonitorSensor(
|
SystemMonitorSensor(
|
||||||
sensor_registry,
|
sensor_registry,
|
||||||
@ -425,7 +425,7 @@ async def async_setup_entry(
|
|||||||
is_enabled = check_legacy_resource(
|
is_enabled = check_legacy_resource(
|
||||||
f"{_type}_{argument}", legacy_resources
|
f"{_type}_{argument}", legacy_resources
|
||||||
)
|
)
|
||||||
loaded_resources.add(f"{_type}_{argument}")
|
loaded_resources.add(f"{_type}_{slugify(argument)}")
|
||||||
entities.append(
|
entities.append(
|
||||||
SystemMonitorSensor(
|
SystemMonitorSensor(
|
||||||
sensor_registry,
|
sensor_registry,
|
||||||
@ -449,7 +449,7 @@ async def async_setup_entry(
|
|||||||
sensor_registry[(_type, argument)] = SensorData(
|
sensor_registry[(_type, argument)] = SensorData(
|
||||||
argument, None, None, None, None
|
argument, None, None, None, None
|
||||||
)
|
)
|
||||||
loaded_resources.add(f"{_type}_{argument}")
|
loaded_resources.add(f"{_type}_{slugify(argument)}")
|
||||||
entities.append(
|
entities.append(
|
||||||
SystemMonitorSensor(
|
SystemMonitorSensor(
|
||||||
sensor_registry,
|
sensor_registry,
|
||||||
@ -478,10 +478,13 @@ async def async_setup_entry(
|
|||||||
# of mount points automatically discovered
|
# of mount points automatically discovered
|
||||||
for resource in legacy_resources:
|
for resource in legacy_resources:
|
||||||
if resource.startswith("disk_"):
|
if resource.startswith("disk_"):
|
||||||
|
check_resource = slugify(resource)
|
||||||
_LOGGER.debug(
|
_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("_")
|
split_index = resource.rfind("_")
|
||||||
_type = resource[:split_index]
|
_type = resource[:split_index]
|
||||||
argument = resource[split_index + 1 :]
|
argument = resource[split_index + 1 :]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user