Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions custom_components/dataplicity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
20 changes: 14 additions & 6 deletions custom_components/dataplicity/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down