mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Bump systembridgeconnector to 5.5.0 (#185220)
This commit is contained in:
@@ -160,6 +160,16 @@ async def async_setup_entry(
|
||||
},
|
||||
) from exception
|
||||
|
||||
if coordinator.data.system is None:
|
||||
raise ConfigEntryNotReady(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="timeout",
|
||||
translation_placeholders={
|
||||
"title": entry.title,
|
||||
"host": entry.data[CONF_HOST],
|
||||
},
|
||||
)
|
||||
|
||||
# Fetch initial data so we have data when entities subscribe
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class SystemBridgeBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||
|
||||
def camera_in_use(data: SystemBridgeData) -> bool | None:
|
||||
"""Return if any camera is in use."""
|
||||
if data.system.camera_usage is not None:
|
||||
if data.system is not None and data.system.camera_usage is not None:
|
||||
return len(data.system.camera_usage) > 0
|
||||
return None
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ class SystemBridgeData:
|
||||
|
||||
battery: Battery = field(default_factory=Battery)
|
||||
cpu: CPU = field(default_factory=CPU)
|
||||
disks: Disks = None
|
||||
disks: Disks | None = None
|
||||
displays: list[Display] = field(default_factory=list[Display])
|
||||
gpus: list[GPU] = field(default_factory=list[GPU])
|
||||
media: Media = field(default_factory=Media)
|
||||
memory: Memory = None
|
||||
memory: Memory | None = None
|
||||
processes: list[Process] = field(default_factory=list[Process])
|
||||
system: System = None
|
||||
system: System | None = None
|
||||
|
||||
@@ -22,18 +22,19 @@ class SystemBridgeEntity(CoordinatorEntity[SystemBridgeDataUpdateCoordinator]):
|
||||
"""Initialize the System Bridge entity."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._hostname = coordinator.data.system.hostname
|
||||
system = coordinator.data.system
|
||||
assert system is not None
|
||||
|
||||
self._hostname = system.hostname
|
||||
self._attr_unique_id = (
|
||||
f"{coordinator.data.system.uuid}_{key}"
|
||||
if key is not None
|
||||
else coordinator.data.system.uuid
|
||||
f"{system.uuid}_{key}" if key is not None else system.uuid
|
||||
)
|
||||
self._configuration_url = (
|
||||
f"http://{self._hostname}:{api_port}/app/settings.html"
|
||||
)
|
||||
self._mac_address = coordinator.data.system.mac_address
|
||||
self._uuid = coordinator.data.system.uuid
|
||||
self._version = coordinator.data.system.version
|
||||
self._mac_address = system.mac_address
|
||||
self._uuid = system.uuid
|
||||
self._version = system.version
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
configuration_url=self._configuration_url,
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["systembridgeconnector"],
|
||||
"requirements": ["systembridgeconnector==5.4.3"],
|
||||
"requirements": ["systembridgeconnector==5.5.0"],
|
||||
"zeroconf": ["_system-bridge._tcp.local."]
|
||||
}
|
||||
|
||||
@@ -191,18 +191,22 @@ def gpu_usage_percentage(gpu: GPU) -> float | None:
|
||||
|
||||
def memory_free(data: SystemBridgeData) -> float | None:
|
||||
"""Return the free memory."""
|
||||
if (virtual := data.memory.virtual) is not None and (
|
||||
free := virtual.free
|
||||
) is not None:
|
||||
if (
|
||||
data.memory is not None
|
||||
and (virtual := data.memory.virtual) is not None
|
||||
and (free := virtual.free) is not None
|
||||
):
|
||||
return round(free / 1000**3, 2)
|
||||
return None
|
||||
|
||||
|
||||
def memory_used(data: SystemBridgeData) -> float | None:
|
||||
"""Return the used memory."""
|
||||
if (virtual := data.memory.virtual) is not None and (
|
||||
used := virtual.used
|
||||
) is not None:
|
||||
if (
|
||||
data.memory is not None
|
||||
and (virtual := data.memory.virtual) is not None
|
||||
and (used := virtual.used) is not None
|
||||
):
|
||||
return round(used / 1000**3, 2)
|
||||
return None
|
||||
|
||||
@@ -214,7 +218,8 @@ def partition_usage(
|
||||
) -> float | None:
|
||||
"""Return the used memory."""
|
||||
if (
|
||||
(devices := data.disks.devices) is not None
|
||||
data.disks is not None
|
||||
and (devices := data.disks.devices) is not None
|
||||
and device_index < len(devices)
|
||||
and (partitions := devices[device_index].partitions) is not None
|
||||
and partition_index < len(partitions)
|
||||
@@ -371,7 +376,10 @@ async def async_setup_entry(
|
||||
for description in BASE_SENSOR_TYPES
|
||||
]
|
||||
|
||||
for index_device, device in enumerate(coordinator.data.disks.devices):
|
||||
disk_devices = (
|
||||
coordinator.data.disks.devices if coordinator.data.disks is not None else []
|
||||
)
|
||||
for index_device, device in enumerate(disk_devices):
|
||||
if device.partitions is None:
|
||||
continue
|
||||
|
||||
|
||||
@@ -52,16 +52,22 @@ class SystemBridgeUpdateEntity(SystemBridgeEntity, UpdateEntity):
|
||||
@override
|
||||
def installed_version(self) -> str | None:
|
||||
"""Version installed and in use."""
|
||||
return self.coordinator.data.system.version
|
||||
if (system := self.coordinator.data.system) is None:
|
||||
return None
|
||||
return system.version
|
||||
|
||||
@property
|
||||
@override
|
||||
def latest_version(self) -> str | None:
|
||||
"""Latest version available for install."""
|
||||
return self.coordinator.data.system.version_latest
|
||||
if (system := self.coordinator.data.system) is None:
|
||||
return None
|
||||
return system.version_latest
|
||||
|
||||
@property
|
||||
@override
|
||||
def release_url(self) -> str | None:
|
||||
"""URL to the full release notes of the latest version available."""
|
||||
return f"https://github.com/timmo001/system-bridge/releases/tag/{self.coordinator.data.system.version_latest}"
|
||||
if (system := self.coordinator.data.system) is None:
|
||||
return None
|
||||
return f"https://github.com/timmo001/system-bridge/releases/tag/{system.version_latest}"
|
||||
|
||||
Generated
+1
-1
@@ -3202,7 +3202,7 @@ switchbot-api==2.13.0
|
||||
synology-srm==0.2.0
|
||||
|
||||
# homeassistant.components.system_bridge
|
||||
systembridgeconnector==5.4.3
|
||||
systembridgeconnector==5.5.0
|
||||
|
||||
# homeassistant.components.tailscale
|
||||
tailscale==0.7.0
|
||||
|
||||
@@ -204,3 +204,30 @@ async def test_coordinator_get_data_timeout(hass: HomeAssistant) -> None:
|
||||
|
||||
assert result is False
|
||||
assert config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_coordinator_get_data_missing_system(hass: HomeAssistant) -> None:
|
||||
"""Test setup retries when get_data returns without system data."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id=FIXTURE_UUID,
|
||||
data=FIXTURE_USER_INPUT,
|
||||
version=SystemBridgeConfigFlow.VERSION,
|
||||
minor_version=SystemBridgeConfigFlow.MINOR_VERSION,
|
||||
)
|
||||
|
||||
with (
|
||||
patch(
|
||||
"systembridgeconnector.version.Version.check_supported",
|
||||
return_value=True,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.system_bridge.coordinator.SystemBridgeDataUpdateCoordinator.async_get_data",
|
||||
),
|
||||
):
|
||||
config_entry.add_to_hass(hass)
|
||||
result = await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result is False
|
||||
assert config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
Reference in New Issue
Block a user