From 2e2d5f9209c8b5b84b13f45d7c723da219b22659 Mon Sep 17 00:00:00 2001 From: Guido Schmitz Date: Tue, 25 Jul 2023 22:04:44 +0200 Subject: [PATCH] Use zeroconf unicast requests --- README.md | 2 +- devolo_plc_api/device.py | 6 ++++-- docs/CHANGELOG.md | 3 ++- pyproject.toml | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 41585c8..da4ff19 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Defining the system requirements with exact versions typically is difficult. But * httpx 0.21.0 * protobuf 3.17.3 * segno 1.5.2 -* zeroconf 0.36.8 +* zeroconf 0.70.0 Other versions and even other operating systems might work. Feel free to tell us about your experience. If you want to run our unit tests, you also need: diff --git a/devolo_plc_api/device.py b/devolo_plc_api/device.py index f9c50b8..d48314f 100644 --- a/devolo_plc_api/device.py +++ b/devolo_plc_api/device.py @@ -242,13 +242,15 @@ def _state_change(self, zeroconf: Zeroconf, service_type: str, name: str, state_ async def _get_service_info(self, zeroconf: Zeroconf, service_type: str, name: str) -> None: """Get service information, if IP matches.""" service_info = AsyncServiceInfo(service_type, name) - question_type = DNSQuestionType.QM if self._multicast else DNSQuestionType.QU update = { DEVICEAPI: self._get_device_info, PLCNETAPI: self._get_plcnet_info, } with suppress(RuntimeError): - await service_info.async_request(zeroconf, timeout=1000, question_type=question_type) + if not self._multicast: + await service_info.async_request(zeroconf, timeout=1000, question_type=DNSQuestionType.QU, addr=self.ip) + else: + await service_info.async_request(zeroconf, timeout=1000, question_type=DNSQuestionType.QM) if not service_info.addresses or self.ip not in service_info.parsed_addresses(): return # No need to continue, if there are no relevant service information diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c23d52d..e676898 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [v1.4.0] - 2023/07/26 ### Added - Generate QR codes from wifi guest settings +- Make use of zeroconf unicast requests to be able to respond across subnets ## [v1.3.2] - 2023/07/13 diff --git a/pyproject.toml b/pyproject.toml index 582ebd9..798e396 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "httpx>=0.21.0", "protobuf>=4.22.0", "segno>=1.5.2", - "zeroconf>=0.32.0", + "zeroconf>=0.70.0", ] dynamic = [ "version",