Skip to content

Commit 5fc7362

Browse files
committed
Fix deprecated device_registry.async_get_device call
async_get_device() is deprecated (removal targeted for 2027.8.0) because device identifiers are no longer guaranteed unique across config entries. Home Assistant logs a deprecation warning on every sw_version update: Detected that custom integration 'solis_modbus' calls device_registry.async_get_device, which is deprecated because device identifiers and connections are no longer unique across config entries Switch to the non-deprecated async_get_devices() (plural), which performs the same identifiers-based lookup without the ambiguity concern, and take the first match to preserve the existing single-device behavior.
1 parent 92dec21 commit 5fc7362

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎custom_components/solis_modbus/sensors/solis_derived_sensor.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def _update_device_sw_version(self, protocol_version) -> None:
210210
if not serial:
211211
return
212212
dev_reg = dr.async_get(self.hass)
213-
device = dev_reg.async_get_device(identifiers={(DOMAIN, serial)})
213+
device = next(iter(dev_reg.async_get_devices(identifiers={(DOMAIN, serial)})), None)
214214
sw_version = f"Protocol {protocol_version}"
215215
if device and device.sw_version != sw_version:
216216
dev_reg.async_update_device(device.id, sw_version=sw_version)

0 commit comments

Comments
 (0)