From 2c73db4c3fe53b775ad07c861b1619eb8dbea05e Mon Sep 17 00:00:00 2001 From: weihuan Date: Fri, 10 Apr 2026 16:21:42 +0800 Subject: [PATCH 1/2] support thirdreality dual plug ZP1 Change-Id: I426eee578dfce969d47b358b68156aa0d8a63939 --- .../zigbee-switch/fingerprints.yml | 5 ++ .../zigbee-switch/src/sub_drivers.lua | 3 +- .../src/thirdreality-dual-plug/init.lua | 85 +++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/init.lua diff --git a/drivers/SmartThings/zigbee-switch/fingerprints.yml b/drivers/SmartThings/zigbee-switch/fingerprints.yml index 8765be8aeb..bd0bd06171 100644 --- a/drivers/SmartThings/zigbee-switch/fingerprints.yml +++ b/drivers/SmartThings/zigbee-switch/fingerprints.yml @@ -1100,6 +1100,11 @@ zigbeeManufacturer: manufacturer: Third Reality, Inc model: 3RSP02028BZ deviceProfileName: switch-power-energy + - id: "Third Reality/3RDP01072Z" + deviceLabel: ThirdReality Smart Dual Plug ZP1 + manufacturer: Third Reality, Inc + model: 3RDP01072Z + deviceProfileName: switch-power-energy - id: "DAWON_DNS/PM-S140-ZB" deviceLabel: Dawon Switch manufacturer: DAWON_DNS diff --git a/drivers/SmartThings/zigbee-switch/src/sub_drivers.lua b/drivers/SmartThings/zigbee-switch/src/sub_drivers.lua index 5dcf24ca74..238b03a6d7 100644 --- a/drivers/SmartThings/zigbee-switch/src/sub_drivers.lua +++ b/drivers/SmartThings/zigbee-switch/src/sub_drivers.lua @@ -35,5 +35,6 @@ return { lazy_load_if_possible("tuya-multi"), lazy_load_if_possible("frient"), lazy_load_if_possible("frient-IO"), - lazy_load_if_possible("color_temp_range_handlers") + lazy_load_if_possible("color_temp_range_handlers"), + lazy_load_if_possible("thirdreality-dual-plug") } diff --git a/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/init.lua b/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/init.lua new file mode 100644 index 0000000000..8faefc9135 --- /dev/null +++ b/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/init.lua @@ -0,0 +1,85 @@ +-- Copyright 2022 SmartThings +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +local capabilities = require "st.capabilities" +local st_device = require "st.device" +local clusters = require "st.zigbee.zcl.clusters" +local OnOff = clusters.OnOff +local ElectricalMeasurement = clusters.ElectricalMeasurement +local utils = require "st.utils" + +local CHILD_ENDPOINT = 2 + +local ZIGBEE_DUAL_METERING_SWITCH_FINGERPRINT = { + {mfr = "Third Reality, Inc", model = "3RDP01072Z"} +} + +local function can_handle_zigbee_dual_metering_switch(opts, driver, device, ...) + for _, fingerprint in ipairs(ZIGBEE_DUAL_METERING_SWITCH_FINGERPRINT) do + if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then + local subdriver = require("thirdreality-dual-plug") + return true, subdriver + end + end + return false +end + +local function do_refresh(self, device) + device:send(OnOff.attributes.OnOff:read(device)) + device:send(ElectricalMeasurement.attributes.ActivePower:read(device)) +end + +local function find_child(parent, ep_id) + return parent:get_child_by_parent_assigned_key(string.format("%02X", ep_id)) +end + +local function device_added(driver, device, event) + if device.network_type == st_device.NETWORK_TYPE_ZIGBEE and + not (device.child_ids and utils.table_size(device.child_ids) ~= 0) and + find_child(device, CHILD_ENDPOINT) == nil then + + local name = "ThirdReality Smart Dual Plug ZP1" + local metadata = { + type = "EDGE_CHILD", + label = name, + profile = "switch-power-energy", + parent_device_id = device.id, + parent_assigned_child_key = string.format("%02X", CHILD_ENDPOINT), + vendor_provided_label = name, + } + driver:try_create_device(metadata) + end + do_refresh(driver, device) +end + +local function device_init(driver, device) + if device.network_type == st_device.NETWORK_TYPE_ZIGBEE then + device:set_find_child(find_child) + end +end + +local zigbee_dual_metering_switch = { + NAME = "ThirdReality Smart Dual Plug ZP1", + capability_handlers = { + [capabilities.refresh.ID] = { + [capabilities.refresh.commands.refresh.NAME] = do_refresh + } + }, + lifecycle_handlers = { + init = device_init, + added = device_added + }, + can_handle = can_handle_zigbee_dual_metering_switch +} + +return zigbee_dual_metering_switch From 69de4db90f136cdf5110beaa27698d906e15e405 Mon Sep 17 00:00:00 2001 From: weihuan Date: Mon, 13 Apr 2026 08:51:40 +0800 Subject: [PATCH 2/2] 1 Change-Id: Ia671499fe8043508e77466809466c750629a9a79 --- .../src/thirdreality-dual-plug/can_handle.lua | 11 +++++++++++ .../src/thirdreality-dual-plug/init.lua | 16 +--------------- 2 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/can_handle.lua diff --git a/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/can_handle.lua b/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/can_handle.lua new file mode 100644 index 0000000000..efde9aab8e --- /dev/null +++ b/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/can_handle.lua @@ -0,0 +1,11 @@ +-- Copyright 2025 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + +local function thirdreality_can_handle(opts, driver, device, ...) + if device:get_manufacturer() == "Third Reality, Inc" and device:get_model() == "3RDP01072Z" then + return true, require("thirdreality-dual-plug") + end + return false +end + +return thirdreality_can_handle diff --git a/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/init.lua b/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/init.lua index 8faefc9135..5245dcd2ac 100644 --- a/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/init.lua +++ b/drivers/SmartThings/zigbee-switch/src/thirdreality-dual-plug/init.lua @@ -20,20 +20,6 @@ local utils = require "st.utils" local CHILD_ENDPOINT = 2 -local ZIGBEE_DUAL_METERING_SWITCH_FINGERPRINT = { - {mfr = "Third Reality, Inc", model = "3RDP01072Z"} -} - -local function can_handle_zigbee_dual_metering_switch(opts, driver, device, ...) - for _, fingerprint in ipairs(ZIGBEE_DUAL_METERING_SWITCH_FINGERPRINT) do - if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then - local subdriver = require("thirdreality-dual-plug") - return true, subdriver - end - end - return false -end - local function do_refresh(self, device) device:send(OnOff.attributes.OnOff:read(device)) device:send(ElectricalMeasurement.attributes.ActivePower:read(device)) @@ -79,7 +65,7 @@ local zigbee_dual_metering_switch = { init = device_init, added = device_added }, - can_handle = can_handle_zigbee_dual_metering_switch + can_handle = require("thirdreality-dual-plug.can_handle"), } return zigbee_dual_metering_switch