mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Added error checking (#29041)
Add in error checking in case disks or volumes are empty.
This commit is contained in:
parent
752a4d7221
commit
63f66785ad
@ -119,24 +119,26 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Handle all volumes
|
# Handle all volumes
|
||||||
for volume in config.get(CONF_VOLUMES, api.storage.volumes):
|
if api.storage.volumes is not None:
|
||||||
sensors += [
|
for volume in config.get(CONF_VOLUMES, api.storage.volumes):
|
||||||
SynoNasStorageSensor(
|
sensors += [
|
||||||
api, name, variable, _STORAGE_VOL_MON_COND[variable], volume
|
SynoNasStorageSensor(
|
||||||
)
|
api, name, variable, _STORAGE_VOL_MON_COND[variable], volume
|
||||||
for variable in monitored_conditions
|
)
|
||||||
if variable in _STORAGE_VOL_MON_COND
|
for variable in monitored_conditions
|
||||||
]
|
if variable in _STORAGE_VOL_MON_COND
|
||||||
|
]
|
||||||
|
|
||||||
# Handle all disks
|
# Handle all disks
|
||||||
for disk in config.get(CONF_DISKS, api.storage.disks):
|
if api.storage.disks is not None:
|
||||||
sensors += [
|
for disk in config.get(CONF_DISKS, api.storage.disks):
|
||||||
SynoNasStorageSensor(
|
sensors += [
|
||||||
api, name, variable, _STORAGE_DSK_MON_COND[variable], disk
|
SynoNasStorageSensor(
|
||||||
)
|
api, name, variable, _STORAGE_DSK_MON_COND[variable], disk
|
||||||
for variable in monitored_conditions
|
)
|
||||||
if variable in _STORAGE_DSK_MON_COND
|
for variable in monitored_conditions
|
||||||
]
|
if variable in _STORAGE_DSK_MON_COND
|
||||||
|
]
|
||||||
|
|
||||||
add_entities(sensors, True)
|
add_entities(sensors, True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user