Update systembridgeconnector to 3.4.8 (#79732)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
755c44d152
commit
85bcf11aeb
4 changed files with 39 additions and 36 deletions
|
@ -10,6 +10,6 @@
|
|||
"iot_class": "local_push",
|
||||
"loggers": ["systembridgeconnector"],
|
||||
"quality_scale": "silver",
|
||||
"requirements": ["systembridgeconnector==3.4.4"],
|
||||
"requirements": ["systembridgeconnector==3.4.8"],
|
||||
"zeroconf": ["_system-bridge._tcp.local."]
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ class SystemBridgeSensorEntityDescription(SensorEntityDescription):
|
|||
|
||||
def battery_time_remaining(data: SystemBridgeCoordinatorData) -> datetime | None:
|
||||
"""Return the battery time remaining."""
|
||||
if data.battery.sensors_secsleft is not None:
|
||||
return utcnow() + timedelta(seconds=data.battery.sensors_secsleft)
|
||||
if (value := getattr(data.battery, "sensors_secsleft", None)) is not None:
|
||||
return utcnow() + timedelta(seconds=value)
|
||||
return None
|
||||
|
||||
|
||||
|
@ -65,29 +65,29 @@ def cpu_speed(data: SystemBridgeCoordinatorData) -> float | None:
|
|||
|
||||
def gpu_core_clock_speed(data: SystemBridgeCoordinatorData, key: str) -> float | None:
|
||||
"""Return the GPU core clock speed."""
|
||||
if getattr(data.gpu, f"{key}_core_clock") is not None:
|
||||
return round(getattr(data.gpu, f"{key}_core_clock"))
|
||||
if (value := getattr(data.gpu, f"{key}_core_clock", None)) is not None:
|
||||
return round(value)
|
||||
return None
|
||||
|
||||
|
||||
def gpu_memory_clock_speed(data: SystemBridgeCoordinatorData, key: str) -> float | None:
|
||||
"""Return the GPU memory clock speed."""
|
||||
if getattr(data.gpu, f"{key}_memory_clock") is not None:
|
||||
return round(getattr(data.gpu, f"{key}_memory_clock"))
|
||||
if (value := getattr(data.gpu, f"{key}_memory_clock", None)) is not None:
|
||||
return round(value)
|
||||
return None
|
||||
|
||||
|
||||
def gpu_memory_free(data: SystemBridgeCoordinatorData, key: str) -> float | None:
|
||||
"""Return the free GPU memory."""
|
||||
if getattr(data.gpu, f"{key}_memory_free") is not None:
|
||||
return round(getattr(data.gpu, f"{key}_memory_free") / 10**3, 2)
|
||||
if (value := getattr(data.gpu, f"{key}_memory_free", None)) is not None:
|
||||
return round(value)
|
||||
return None
|
||||
|
||||
|
||||
def gpu_memory_used(data: SystemBridgeCoordinatorData, key: str) -> float | None:
|
||||
"""Return the used GPU memory."""
|
||||
if getattr(data.gpu, f"{key}_memory_used") is not None:
|
||||
return round(getattr(data.gpu, f"{key}_memory_used") / 10**3, 2)
|
||||
if (value := getattr(data.gpu, f"{key}_memory_used", None)) is not None:
|
||||
return round(value)
|
||||
return None
|
||||
|
||||
|
||||
|
@ -95,14 +95,11 @@ def gpu_memory_used_percentage(
|
|||
data: SystemBridgeCoordinatorData, key: str
|
||||
) -> float | None:
|
||||
"""Return the used GPU memory percentage."""
|
||||
if (
|
||||
getattr(data.gpu, f"{key}_memory_used") is not None
|
||||
and getattr(data.gpu, f"{key}_memory_total") is not None
|
||||
if ((used := getattr(data.gpu, f"{key}_memory_used", None)) is not None) and (
|
||||
(total := getattr(data.gpu, f"{key}_memory_total", None)) is not None
|
||||
):
|
||||
return round(
|
||||
getattr(data.gpu, f"{key}_memory_used")
|
||||
/ getattr(data.gpu, f"{key}_memory_total")
|
||||
* 100,
|
||||
used / total * 100,
|
||||
2,
|
||||
)
|
||||
return None
|
||||
|
@ -266,7 +263,7 @@ async def async_setup_entry(
|
|||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon="mdi:harddisk",
|
||||
value=lambda data, p=partition: getattr(
|
||||
data.disk, f"usage_{p}_percent"
|
||||
data.disk, f"usage_{p}_percent", None
|
||||
),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
|
@ -283,15 +280,17 @@ async def async_setup_entry(
|
|||
SystemBridgeSensor(coordinator, description, entry.data[CONF_PORT])
|
||||
)
|
||||
|
||||
displays = []
|
||||
for display in coordinator.data.display.displays:
|
||||
displays.append(
|
||||
displays: list[dict[str, str]] = []
|
||||
if coordinator.data.display.displays is not None:
|
||||
displays.extend(
|
||||
{
|
||||
"key": display,
|
||||
"name": getattr(coordinator.data.display, f"{display}_name").replace(
|
||||
"Display ", ""
|
||||
),
|
||||
},
|
||||
}
|
||||
for display in coordinator.data.display.displays
|
||||
if hasattr(coordinator.data.display, f"{display}_name")
|
||||
)
|
||||
display_count = len(displays)
|
||||
|
||||
|
@ -321,7 +320,7 @@ async def async_setup_entry(
|
|||
native_unit_of_measurement=PIXELS,
|
||||
icon="mdi:monitor",
|
||||
value=lambda data, k=display["key"]: getattr(
|
||||
data.display, f"{k}_resolution_horizontal"
|
||||
data.display, f"{k}_resolution_horizontal", None
|
||||
),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
|
@ -335,7 +334,7 @@ async def async_setup_entry(
|
|||
native_unit_of_measurement=PIXELS,
|
||||
icon="mdi:monitor",
|
||||
value=lambda data, k=display["key"]: getattr(
|
||||
data.display, f"{k}_resolution_vertical"
|
||||
data.display, f"{k}_resolution_vertical", None
|
||||
),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
|
@ -350,20 +349,22 @@ async def async_setup_entry(
|
|||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
icon="mdi:monitor",
|
||||
value=lambda data, k=display["key"]: getattr(
|
||||
data.display, f"{k}_refresh_rate"
|
||||
data.display, f"{k}_refresh_rate", None
|
||||
),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
),
|
||||
]
|
||||
|
||||
gpus = []
|
||||
for gpu in coordinator.data.gpu.gpus:
|
||||
gpus.append(
|
||||
gpus: list[dict[str, str]] = []
|
||||
if coordinator.data.gpu.gpus is not None:
|
||||
gpus.extend(
|
||||
{
|
||||
"key": gpu,
|
||||
"name": getattr(coordinator.data.gpu, f"{gpu}_name"),
|
||||
},
|
||||
}
|
||||
for gpu in coordinator.data.gpu.gpus
|
||||
if hasattr(coordinator.data.gpu, f"{gpu}_name")
|
||||
)
|
||||
|
||||
for index, gpu in enumerate(gpus):
|
||||
|
@ -448,7 +449,7 @@ async def async_setup_entry(
|
|||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||
icon="mdi:fan",
|
||||
value=lambda data, k=gpu["key"]: getattr(
|
||||
data.gpu, f"{k}_fan_speed"
|
||||
data.gpu, f"{k}_fan_speed", None
|
||||
),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
|
@ -462,7 +463,9 @@ async def async_setup_entry(
|
|||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
value=lambda data, k=gpu["key"]: getattr(data.gpu, f"{k}_power"),
|
||||
value=lambda data, k=gpu["key"]: getattr(
|
||||
data.gpu, f"{k}_power", None
|
||||
),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
),
|
||||
|
@ -476,7 +479,7 @@ async def async_setup_entry(
|
|||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
value=lambda data, k=gpu["key"]: getattr(
|
||||
data.gpu, f"{k}_temperature"
|
||||
data.gpu, f"{k}_temperature", None
|
||||
),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
|
@ -490,7 +493,7 @@ async def async_setup_entry(
|
|||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon="mdi:percent",
|
||||
value=lambda data, k=gpu["key"]: getattr(
|
||||
data.gpu, f"{k}_core_load"
|
||||
data.gpu, f"{k}_core_load", None
|
||||
),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
|
@ -509,7 +512,7 @@ async def async_setup_entry(
|
|||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon="mdi:percent",
|
||||
value=lambda data, k=index: getattr(data.cpu, f"usage_{k}"),
|
||||
value=lambda data, k=index: getattr(data.cpu, f"usage_{k}", None),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
),
|
||||
|
|
|
@ -2449,7 +2449,7 @@ swisshydrodata==0.1.0
|
|||
synology-srm==0.2.0
|
||||
|
||||
# homeassistant.components.system_bridge
|
||||
systembridgeconnector==3.4.4
|
||||
systembridgeconnector==3.4.8
|
||||
|
||||
# homeassistant.components.tailscale
|
||||
tailscale==0.2.0
|
||||
|
|
|
@ -1743,7 +1743,7 @@ sunwatcher==0.2.1
|
|||
surepy==0.8.0
|
||||
|
||||
# homeassistant.components.system_bridge
|
||||
systembridgeconnector==3.4.4
|
||||
systembridgeconnector==3.4.8
|
||||
|
||||
# homeassistant.components.tailscale
|
||||
tailscale==0.2.0
|
||||
|
|
Loading…
Add table
Reference in a new issue