From 58fc6070950213470697f0b5f8dbcf0e0610877f Mon Sep 17 00:00:00 2001 From: qjrxsoft02 <153160482+qjrxsoft02@users.noreply.github.com> Date: Mon, 8 Sep 2025 23:24:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Add=20support=20Xiaomi=20Label=20printer=20?= =?UTF-8?q?=EF=BC=88xiaomi.printer.label=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code defines a device driver configuration that: Standardizes state data for Xiaomi Label Printers (errors, battery, paper status). Converts low-level hardware register values into user-friendly semantic states (e.g., working, overheat). Provides device integration specifications for Home Assistant , enabling status monitoring and automation control. --- custom_components/xiaomi_gateway3/core/devices.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/custom_components/xiaomi_gateway3/core/devices.py b/custom_components/xiaomi_gateway3/core/devices.py index b0797f4d..50e9fe42 100644 --- a/custom_components/xiaomi_gateway3/core/devices.py +++ b/custom_components/xiaomi_gateway3/core/devices.py @@ -1488,6 +1488,19 @@ BLEByteConv("supply", "sensor", mi=4115), # uint8, Remaining percentage, range 0~100 BLEToothbrush("toothbrush", mi=16), ], +}, { + # MIOT https://home.miot-spec.com/spec?type=urn:miot-spec-v2:device:printer:0000A060:xiaomi-label:1 + 13566: ["Xiaomi", "Label printer", "MJBQDYJ1-WC","xiaomi.printer.label"], + "spec": [ + MapConv("printer_state", "sensor", mi="2.p.1", map={ 0: "standby", 1: "working", 2: "complete", 3: "suspend"}), + BaseConv("copies", "sensor", mi="2.p.3"), + MapConv("paper_lack", "binary_sensor", mi="2.p.4", map={ True: "True", False: "False"}), + MapConv("cover_open", "binary_sensor", mi="2.p.5", map={ True: "True", False: "False"}), + MapConv("fault", "sensor", mi="2.p.6", map={ 0: "normal",1: "paper_lack", 2: "cover_open", 3: "overheat"}), + BaseConv("battery", "sensor", mi="3.p.1"), + MathConv("battery_low", "binary_sensor", mi="3.p.1", multiply=0.01, min=0, max=0.2 ) + ], + "ttl": 600 }, { 1249: ["Xiaomi", "Magic Cube", "XMMF01JQD", "jiqid.robot.cube"], # 4097 "spec": [ From cb55e469cddc2a33d6b3aca2dbde22eb02b4c9a2 Mon Sep 17 00:00:00 2001 From: qjrxsoft02 <153160482+qjrxsoft02@users.noreply.github.com> Date: Tue, 9 Sep 2025 13:32:07 +0800 Subject: [PATCH 2/2] Fix the following issues recorded in #1654 for proper functioning in the Xiaomi Gateway 3 integration. Fix the following issues recorded in #1654 for proper functioning in the Xiaomi Gateway 3 integration. --- .../xiaomi_gateway3/core/devices.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/custom_components/xiaomi_gateway3/core/devices.py b/custom_components/xiaomi_gateway3/core/devices.py index 50e9fe42..1a36d388 100644 --- a/custom_components/xiaomi_gateway3/core/devices.py +++ b/custom_components/xiaomi_gateway3/core/devices.py @@ -1489,18 +1489,17 @@ BLEToothbrush("toothbrush", mi=16), ], }, { - # MIOT https://home.miot-spec.com/spec?type=urn:miot-spec-v2:device:printer:0000A060:xiaomi-label:1 - 13566: ["Xiaomi", "Label printer", "MJBQDYJ1-WC","xiaomi.printer.label"], - "spec": [ - MapConv("printer_state", "sensor", mi="2.p.1", map={ 0: "standby", 1: "working", 2: "complete", 3: "suspend"}), - BaseConv("copies", "sensor", mi="2.p.3"), - MapConv("paper_lack", "binary_sensor", mi="2.p.4", map={ True: "True", False: "False"}), - MapConv("cover_open", "binary_sensor", mi="2.p.5", map={ True: "True", False: "False"}), - MapConv("fault", "sensor", mi="2.p.6", map={ 0: "normal",1: "paper_lack", 2: "cover_open", 3: "overheat"}), - BaseConv("battery", "sensor", mi="3.p.1"), - MathConv("battery_low", "binary_sensor", mi="3.p.1", multiply=0.01, min=0, max=0.2 ) - ], - "ttl": 600 + # MIOT https://home.miot-spec.com/spec?type=urn:miot-spec-v2:device:printer:0000A060:xiaomi-label:1 + 13566: ["Xiaomi", "Label printer", "MJBQDYJ1-WC", "xiaomi.printer.label"], + "spec": [ + MapConv("printer_state", "sensor", mi="2.p.1", map={0: "standby", 1: "working", 2: "complete", 3: "suspend"}), + BaseConv("copies", "sensor", mi="2.p.3"), + MapConv("paper_lack", "binary_sensor", mi="2.p.4", map={1: True, 0: False}), + MapConv("cover_open", "binary_sensor", mi="2.p.5", map={1: True, 0: False}), + MapConv("fault", "sensor", mi="2.p.6", map={0: "normal", 1: "paper_lack", 2: "cover_open", 3: "overheat"}), + BaseConv("battery", "sensor", mi="3.p.1"), +], + "ttl": "10m" }, { 1249: ["Xiaomi", "Magic Cube", "XMMF01JQD", "jiqid.robot.cube"], # 4097 "spec": [