diff --git a/CHANGELOG.md b/CHANGELOG.md index 0637fc6..b43ffe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,15 @@ All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow [Semantic Versioning](https://semver.org/). +## [2.0.2] - 2026-09-29 + +### Fixed + +- `RadioPacket.dbm` is `None` for telegrams to send (those built by `RadioPacket.create()`, the actuators and UTE + teach-in responses), instead of -255: their dBm byte is 0xFF, which ESP3 uses when sending, not a signal strength. + This also fixes `to_dict()`, the `dbm` field of the `Sending` log, and `str(packet)`, which no longer shows a signal + strength when there is none. + ## [2.0.1] - 2026-09-29 ### Fixed @@ -139,6 +148,7 @@ First release of the [j5lien/enocean](https://github.com/j5lien/enocean) fork of Last release of [kipe/enocean](https://github.com/kipe/enocean). +[2.0.2]: https://github.com/j5lien/enocean/compare/2.0.1...2.0.2 [2.0.1]: https://github.com/j5lien/enocean/compare/2.0.0...2.0.1 [2.0.0]: https://github.com/j5lien/enocean/compare/1.0.0...2.0.0 [1.0.0]: https://github.com/j5lien/enocean/compare/0.60.1...1.0.0 diff --git a/README.md b/README.md index dab1b89..64cd96d 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ This is a maintained fork of [kipe/enocean](https://github.com/kipe/enocean), wh Requires Python 3.10 or later. ```bash -pip install git+https://github.com/j5lien/enocean.git@2.0.1 +pip install git+https://github.com/j5lien/enocean.git@2.0.2 # or, in a uv-managed project -uv add git+https://github.com/j5lien/enocean.git --tag 2.0.1 +uv add git+https://github.com/j5lien/enocean.git --tag 2.0.2 ``` Wheels are also attached to each [GitHub release](https://github.com/j5lien/enocean/releases); see diff --git a/TODO.md b/TODO.md index 0de2363..143695c 100644 --- a/TODO.md +++ b/TODO.md @@ -142,3 +142,4 @@ aujourd'hui) ; on **s'aligne sur les noms officiels** des champs (version 2.0). et trames réelles en tests CI (PTM 210 F6-02-02, SIN-2-2-01 D2-01-12) - [x] Release 2.0.0 : profils officiels, API d'intégration, supervision, documentation - [x] Release 2.0.1 : `status` et `repeater_count` des télégrammes VLD (lus dans le niveau de sécurité) +- [x] Release 2.0.2 : `dbm` à `None` au lieu de -255 pour les télégrammes à envoyer diff --git a/docs/getting-started.md b/docs/getting-started.md index dc27fea..489780b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -3,11 +3,11 @@ ## Installation ```bash -pip install git+https://github.com/j5lien/enocean.git@2.0.1 +pip install git+https://github.com/j5lien/enocean.git@2.0.2 # or, in a uv-managed project -uv add git+https://github.com/j5lien/enocean.git --tag 2.0.1 +uv add git+https://github.com/j5lien/enocean.git --tag 2.0.2 # with Prometheus metrics -pip install "enocean[prometheus] @ git+https://github.com/j5lien/enocean.git@2.0.1" +pip install "enocean[prometheus] @ git+https://github.com/j5lien/enocean.git@2.0.2" ``` ## Finding the module's serial port diff --git a/docs/index.md b/docs/index.md index 52675b4..7c35934 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,7 +14,7 @@ actuators…) through an EnOcean USB/serial module (e.g. USB 300) or a TCP bridg It requires Python 3.10 or later, and has one dependency: `pyserial`. ```bash -pip install git+https://github.com/j5lien/enocean.git@2.0.1 +pip install git+https://github.com/j5lien/enocean.git@2.0.2 ``` ```python diff --git a/enocean/protocol/packet.py b/enocean/protocol/packet.py index 5986f37..22663a1 100644 --- a/enocean/protocol/packet.py +++ b/enocean/protocol/packet.py @@ -501,7 +501,8 @@ class RadioPacket(Packet): """A radio telegram (ERP1). Attributes set when parsing: `sender` / `destination` (4-byte IDs, also as `sender_hex` / `destination_hex`), - `dbm` (signal strength of the received telegram, None if the module didn't report it) and `learn`. + `dbm` (signal strength of the received telegram, None if the module didn't report it and for telegrams to send) + and `learn`. `learn` tells whether the telegram can be used to teach the device in. 1BS and 4BS telegrams carry a learn bit, UTE telegrams a teach-in request; RPS and VLD telegrams have no learn bit, so `learn` is always True for them: @@ -518,6 +519,8 @@ class RadioPacket(Packet): def __str__(self) -> str: packet_str = super().__str__() + if self.dbm is None: + return '%s->%s: %s' % (self.sender_hex, self.destination_hex, packet_str) return '%s->%s (%s dBm): %s' % (self.sender_hex, self.destination_hex, self.dbm, packet_str) @property @@ -588,7 +591,8 @@ def parse(self) -> OrderedDict[str, FieldValue]: # Optional data (sub-telegram count, destination, dBm, security level) may be omitted if len(self.optional) >= 6: self.destination = self.optional[1:5] - self.dbm = -self.optional[5] + # 0xFF is what telegrams to send carry (e.g. those built by create()): not a signal strength + self.dbm = None if self.optional[5] == 0xFF else -self.optional[5] self.sender = self.data[-5:-1] # RPS and VLD have no learn bit: any of their telegrams may be used for teach-in self.learn = True diff --git a/enocean/protocol/tests/test_packet.py b/enocean/protocol/tests/test_packet.py index e69b642..c6694f4 100644 --- a/enocean/protocol/tests/test_packet.py +++ b/enocean/protocol/tests/test_packet.py @@ -247,3 +247,23 @@ def test_dbm_and_deprecated_dBm(): # noqa: N802 with pytest.warns(DeprecationWarning): assert packet.dBm == -58 assert RadioPacket(PACKET.RADIO_ERP1, [RORG.RPS, 0x10, 1, 2, 3, 4, 0x30], []).dbm is None + assert RadioPacket(PACKET.RADIO_ERP1, [RORG.RPS, 0x10, 1, 2, 3, 4, 0x30], [0x01, 0xFF, 0xFF]).dbm is None + assert str(packet).startswith('01:02:03:04->FF:FF:FF:FF (-58 dBm): ') + + +def test_no_dbm_on_telegrams_to_send(): + """Telegrams to send carry 0xFF in place of the signal strength (ESP3), not -255 dBm.""" + packet = RadioPacket.create( + rorg=RORG.VLD, + rorg_func=0x01, + rorg_type=0x12, + command=1, + destination=[0x05, 0x99, 0x77, 0xAF], + sender=[0xFF, 0xF5, 0xB4, 0x80], + IO=1, + OV=100, + ) + assert packet.optional[5] == 0xFF + assert packet.dbm is None + assert packet.to_dict()['dbm'] is None + assert str(packet).startswith('FF:F5:B4:80->05:99:77:AF: ') diff --git a/enocean/protocol/tests/test_real_frames.py b/enocean/protocol/tests/test_real_frames.py index 94388d2..7a90488 100644 --- a/enocean/protocol/tests/test_real_frames.py +++ b/enocean/protocol/tests/test_real_frames.py @@ -60,6 +60,7 @@ def test_d2_01_12_actuator_status(payload, output): packet, values = decode(radio_frame(RORG.VLD, payload, OFFICE_LIGHT, 0x00, -73), 0x01, 0x12, command=4) assert packet.sender_hex == '05:99:77:AF' + assert packet.dbm == -73 assert packet.command == 4 assert values['IO'] == 'Output channel (to load): 1' assert values['OV'] == output diff --git a/enocean/protocol/tests/test_teachin.py b/enocean/protocol/tests/test_teachin.py index 935fcc9..3647bcc 100644 --- a/enocean/protocol/tests/test_teachin.py +++ b/enocean/protocol/tests/test_teachin.py @@ -39,6 +39,7 @@ def test_ute_in(): response_packet = packet.create_response_packet(communicator.base_id) assert response_packet.sender_hex == 'DE:AD:BE:EF' assert response_packet.destination_hex == '01:94:E3:B9' + assert response_packet.dbm is None assert response_packet._bit_data[DB6.BIT_5 : DB6.BIT_3] == [False, True] assert response_packet.data[2:7] == packet.data[2:7] diff --git a/enocean/tests/test_actuators.py b/enocean/tests/test_actuators.py index f899f1a..db29ba6 100644 --- a/enocean/tests/test_actuators.py +++ b/enocean/tests/test_actuators.py @@ -26,6 +26,8 @@ def test_switch_turn_on_matches_a_real_controller(communicator): assert payload == [0x01, 0x01, 0x64] assert packet.sender_hex == 'FF:C3:6F:80' assert packet.optional[1:5] == [0x05, 0x99, 0x77, 0xAF] + assert packet.dbm is None + assert packet.to_dict()['dbm'] is None def test_switch_commands(communicator): diff --git a/pyproject.toml b/pyproject.toml index 149d92d..1c0c698 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "enocean" -version = "2.0.1" +version = "2.0.2" description = "EnOcean serial protocol (ESP3) and equipment profiles (EEP) implementation" readme = "README.md" classifiers = [ diff --git a/uv.lock b/uv.lock index e0e6540..a2e72fa 100644 --- a/uv.lock +++ b/uv.lock @@ -418,7 +418,7 @@ toml = [ [[package]] name = "enocean" -version = "2.0.1" +version = "2.0.2" source = { editable = "." } dependencies = [ { name = "pyserial" },