Add raid array degraded state binary sensor to freebox sensors (#95242)

Add raid array degraded state binary sensor
This commit is contained in:
Florent Thiery 2023-07-05 15:09:12 +02:00 committed by GitHub
parent c75c79962a
commit bd7057f7b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 296 additions and 36 deletions

View file

@ -93,75 +93,177 @@ DATA_STORAGE_GET_DISKS = [
{
"idle_duration": 0,
"read_error_requests": 0,
"read_requests": 110,
"read_requests": 1815106,
"spinning": True,
# "table_type": "ms-dos", API returns without dash, but codespell isn't agree
"firmware": "SC1D",
"type": "internal",
"idle": False,
"connector": 0,
"id": 0,
"table_type": "raid",
"firmware": "0001",
"type": "sata",
"idle": True,
"connector": 2,
"id": 1000,
"write_error_requests": 0,
"state": "enabled",
"write_requests": 2708929,
"total_bytes": 250050000000,
"model": "ST9250311CS",
"time_before_spindown": 600,
"state": "disabled",
"write_requests": 80386151,
"total_bytes": 2000000000000,
"model": "ST2000LM015-2E8174",
"active_duration": 0,
"temp": 40,
"serial": "6VCQY907",
"temp": 30,
"serial": "ZDZLBFHC",
"partitions": [
{
"fstype": "ext4",
"total_bytes": 244950000000,
"label": "Disque dur",
"id": 2,
"internal": True,
"fstype": "raid",
"total_bytes": 0,
"label": "Volume 2000Go",
"id": 1000,
"internal": False,
"fsck_result": "no_run_yet",
"state": "mounted",
"disk_id": 0,
"free_bytes": 227390000000,
"used_bytes": 5090000000,
"path": "L0Rpc3F1ZSBkdXI=",
"state": "umounted",
"disk_id": 1000,
"free_bytes": 0,
"used_bytes": 0,
"path": "L1ZvbHVtZSAyMDAwR28=",
}
],
},
{
"idle_duration": 8290,
"idle_duration": 0,
"read_error_requests": 0,
"read_requests": 2326826,
"spinning": False,
"table_type": "gpt",
"read_requests": 3622038,
"spinning": True,
"table_type": "raid",
"firmware": "0001",
"type": "sata",
"idle": True,
"connector": 0,
"id": 2000,
"write_error_requests": 0,
"state": "enabled",
"write_requests": 122733632,
"time_before_spindown": 600,
"state": "disabled",
"write_requests": 80386151,
"total_bytes": 2000000000000,
"model": "ST2000LM015-2E8174",
"active_duration": 0,
"temp": 31,
"serial": "ZDZLEJXE",
"partitions": [
{
"fstype": "raid",
"total_bytes": 0,
"label": "Volume 2000Go 1",
"id": 2000,
"internal": False,
"fsck_result": "no_run_yet",
"state": "umounted",
"disk_id": 2000,
"free_bytes": 0,
"used_bytes": 0,
"path": "L1ZvbHVtZSAyMDAwR28gMQ==",
}
],
},
{
"idle_duration": 0,
"read_error_requests": 0,
"read_requests": 0,
"spinning": False,
"table_type": "superfloppy",
"firmware": "",
"type": "raid",
"idle": False,
"connector": 0,
"id": 3000,
"write_error_requests": 0,
"state": "enabled",
"write_requests": 0,
"total_bytes": 2000000000000,
"model": "",
"active_duration": 0,
"temp": 0,
"serial": "WDZYJ27Q",
"serial": "",
"partitions": [
{
"fstype": "ext4",
"total_bytes": 1960000000000,
"label": "Disque 2",
"id": 2001,
"label": "Freebox",
"id": 3000,
"internal": False,
"fsck_result": "no_run_yet",
"state": "mounted",
"disk_id": 2000,
"free_bytes": 1880000000000,
"used_bytes": 85410000000,
"path": "L0Rpc3F1ZSAy",
"disk_id": 3000,
"free_bytes": 1730000000000,
"used_bytes": 236910000000,
"path": "L0ZyZWVib3g=",
}
],
},
]
DATA_STORAGE_GET_RAIDS = [
{
"degraded": False,
"raid_disks": 2, # Number of members that should be in this array
"next_check": 0, # Unix timestamp of next check in seconds. Might be 0 if check_interval is 0
"sync_action": "idle", # values: idle, resync, recover, check, repair, reshape, frozen
"level": "raid1", # values: basic, raid0, raid1, raid5, raid10
"uuid": "dc8679f8-13f9-11ee-9106-38d547790df8",
"sysfs_state": "clear", # values: clear, inactive, suspended, readonly, read_auto, clean, active, write_pending, active_idle
"id": 0,
"sync_completed_pos": 0, # Current position of sync process
"members": [
{
"total_bytes": 2000000000000,
"active_device": 1,
"id": 1000,
"corrected_read_errors": 0,
"array_id": 0,
"disk": {
"firmware": "0001",
"temp": 29,
"serial": "ZDZLBFHC",
"model": "ST2000LM015-2E8174",
},
"role": "active", # values: active, faulty, spare, missing
"sct_erc_supported": False,
"sct_erc_enabled": False,
"dev_uuid": "fca8720e-13f9-11ee-9106-38d547790df8",
"device_location": "sata-internal-p2",
"set_name": "Freebox",
"set_uuid": "dc8679f8-13f9-11ee-9106-38d547790df8",
},
{
"total_bytes": 2000000000000,
"active_device": 0,
"id": 2000,
"corrected_read_errors": 0,
"array_id": 0,
"disk": {
"firmware": "0001",
"temp": 30,
"serial": "ZDZLEJXE",
"model": "ST2000LM015-2E8174",
},
"role": "active",
"sct_erc_supported": False,
"sct_erc_enabled": False,
"dev_uuid": "16bf00d6-13fa-11ee-9106-38d547790df8",
"device_location": "sata-internal-p0",
"set_name": "Freebox",
"set_uuid": "dc8679f8-13f9-11ee-9106-38d547790df8",
},
],
"array_size": 2000000000000, # Size of array in bytes
"state": "running", # stopped, running, error
"sync_speed": 0, # Sync speed in bytes per second
"name": "Freebox",
"check_interval": 0, # Check interval in seconds
"disk_id": 3000,
"last_check": 1682884357, # Unix timestamp of last check in seconds
"sync_completed_end": 0, # End position of sync process: total of bytes to sync
"sync_completed_percent": 0, # Percentage of sync completion
}
]
# switch
WIFI_GET_GLOBAL_CONFIG = {"enabled": True, "mac_filter_state": "disabled"}