Fix error with HDD temperature report in Freebox integration (#74718)

* Fix error whith HDD temperature report

There was a non handled error case, documented in issue https://github.com/home-assistant/core/issues/43812 back in 2020 and the fix wasn't applied

* Use get method instead of ignoring the sensor

* Update test values

Add idle state drive with unkown temp

* update Tests for system sensors api

* Fix booleans values

* Fix disk unique_id

There was a typo in the code
This commit is contained in:
Benoit Anastay 2022-07-08 23:22:31 +02:00 committed by GitHub
parent 0cca086aab
commit 766523cf8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 3 deletions

View file

@ -113,7 +113,7 @@ class FreeboxRouter:
# According to the doc `syst_datas["sensors"]` is temperature sensors in celsius degree.
# Name and id of sensors may vary under Freebox devices.
for sensor in syst_datas["sensors"]:
self.sensors_temperature[sensor["name"]] = sensor["value"]
self.sensors_temperature[sensor["name"]] = sensor.get("value")
# Connection sensors
connection_datas: dict[str, Any] = await self._api.connection.get_status()

View file

@ -159,7 +159,7 @@ class FreeboxDiskSensor(FreeboxSensor):
self._disk = disk
self._partition = partition
self._attr_name = f"{partition['label']} {description.name}"
self._unique_id = f"{self._router.mac} {description.key} {self._disk['id']} {self._partition['id']}"
self._attr_unique_id = f"{self._router.mac} {description.key} {self._disk['id']} {self._partition['id']}"
@property
def device_info(self) -> DeviceInfo:

View file

@ -22,6 +22,7 @@ DATA_SYSTEM_GET_CONFIG = {
"fans": [{"id": "fan0_speed", "name": "Ventilateur 1", "value": 2130}],
"sensors": [
{"id": "temp_hdd", "name": "Disque dur", "value": 40},
{"id": "temp_hdd2", "name": "Disque dur 2"},
{"id": "temp_sw", "name": "Température Switch", "value": 50},
{"id": "temp_cpum", "name": "Température CPU M", "value": 60},
{"id": "temp_cpub", "name": "Température CPU B", "value": 56},
@ -123,7 +124,42 @@ DATA_STORAGE_GET_DISKS = [
"path": "L0Rpc3F1ZSBkdXI=",
}
],
}
},
{
"idle_duration": 8290,
"read_error_requests": 0,
"read_requests": 2326826,
"spinning": False,
"table_type": "gpt",
"firmware": "0001",
"type": "sata",
"idle": True,
"connector": 0,
"id": 2000,
"write_error_requests": 0,
"state": "enabled",
"write_requests": 122733632,
"total_bytes": 2000000000000,
"model": "ST2000LM015-2E8174",
"active_duration": 0,
"temp": 0,
"serial": "WDZYJ27Q",
"partitions": [
{
"fstype": "ext4",
"total_bytes": 1960000000000,
"label": "Disque 2",
"id": 2001,
"internal": False,
"fsck_result": "no_run_yet",
"state": "mounted",
"disk_id": 2000,
"free_bytes": 1880000000000,
"used_bytes": 85410000000,
"path": "L0Rpc3F1ZSAy",
}
],
},
]
# switch