From 1b3d5bdfc3f53e3b7c86707f328154e27970fbfc Mon Sep 17 00:00:00 2001 From: Alex Ultra Date: Tue, 2 Jun 2026 19:35:29 +0200 Subject: [PATCH] Bump dataplicity agent to 0.5.13 to fix 403 on device-gateway devices The pinned 0.4.40 agent talks to the legacy api.dataplicity.com and is rejected (HTTP 403, agent disk-poll/sync fails) for devices provisioned via the new device-gateway API that the integration already uses. 0.5.13 works with the new provisioning. iptool/device_meta were dropped in newer releases, so their compatibility monkey-patches in import_client() are made best-effort. --- custom_components/dataplicity/__init__.py | 8 +++++--- custom_components/dataplicity/utils.py | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/custom_components/dataplicity/__init__.py b/custom_components/dataplicity/__init__.py index 5055061..70c3a5a 100644 --- a/custom_components/dataplicity/__init__.py +++ b/custom_components/dataplicity/__init__.py @@ -16,15 +16,17 @@ async def async_setup(hass: HomeAssistant, hass_config: dict): real_install = package.install_package def fake_install(pkg: str, *args, **kwargs): - if pkg == "dataplicity==0.4.40": + if pkg == "dataplicity==0.5.13": return utils.install_package(pkg, *args, **kwargs) return real_install(pkg, *args, **kwargs) try: package.install_package = fake_install - # latest dataplicity has bug with redirect_port - await async_process_requirements(hass, DOMAIN, ["dataplicity==0.4.40"]) + # 0.4.40 talks to the legacy api.dataplicity.com and is rejected with + # HTTP 403 for devices provisioned via the new device-gateway API; + # 0.5.13 works with the new provisioning. + await async_process_requirements(hass, DOMAIN, ["dataplicity==0.5.13"]) # fix Python 3.11 support if not hasattr(inspect, "getargspec"): diff --git a/custom_components/dataplicity/utils.py b/custom_components/dataplicity/utils.py index 0ed019d..ae2420a 100644 --- a/custom_components/dataplicity/utils.py +++ b/custom_components/dataplicity/utils.py @@ -144,14 +144,22 @@ def install_package( def import_client(): # fix: type object 'array.array' has no attribute 'tostring' - from dataplicity import iptool - - iptool.get_all_interfaces = lambda: [("lo", "127.0.0.1")] + # iptool/device_meta were dropped in newer dataplicity releases, so the + # monkey-patches are best-effort (skipped when the module is gone). + try: + from dataplicity import iptool + except ImportError: + pass + else: + iptool.get_all_interfaces = lambda: [("lo", "127.0.0.1")] # fix: module 'platform' has no attribute 'linux_distribution' - from dataplicity import device_meta - - device_meta.get_os_version = lambda: "Linux" + try: + from dataplicity import device_meta + except ImportError: + pass + else: + device_meta.get_os_version = lambda: "Linux" from dataplicity.client import Client