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
5 changes: 5 additions & 0 deletions drivers/SmartThings/zigbee-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drivers/SmartThings/zigbee-switch/src/sub_drivers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Original file line number Diff line number Diff line change
@@ -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
Loading