Skip to content

Commit

Permalink
adding "private mode" check (#1732)
Browse files Browse the repository at this point in the history
  • Loading branch information
seojune79 authored Nov 15, 2024
1 parent 91fbde8 commit 98b7d7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/aqara/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ local function wireless_switch_handler(driver, device, value, zb_rx)
end

local function energy_meter_power_consumption_report(driver, device, value, zb_rx)
-- ignore unexpected event when the device is private mode
local private_mode = device:get_field(PRIVATE_MODE) or 0
if private_mode == 1 then return end

local raw_value = value.value
-- energy meter
local offset = device:get_field(constants.ENERGY_METER_OFFSET) or 0
Expand Down Expand Up @@ -196,6 +200,10 @@ local function energy_meter_power_consumption_report(driver, device, value, zb_r
end

local function power_meter_handler(driver, device, value, zb_rx)
-- ignore unexpected event when the device is private mode
local private_mode = device:get_field(PRIVATE_MODE) or 0
if private_mode == 1 then return end

local raw_value = value.value -- '10W'
raw_value = raw_value / 10
device:emit_event(capabilities.powerMeter.power({ value = raw_value, unit = "W" }))
Expand Down
4 changes: 4 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/aqara/version/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ local function round(num)
end

local function present_value_handler(driver, device, value, zb_rx)
-- ignore unexpected event when the device is not private mode
local private_mode = device:get_field(PRIVATE_MODE) or 0
if private_mode == 0 then return end

local src_endpoint = zb_rx.address_header.src_endpoint.value
if src_endpoint == POWER_METER_ENDPOINT then
-- power meter
Expand Down

0 comments on commit 98b7d7d

Please sign in to comment.