Skip to content

Commit

Permalink
Add device not support battery percent remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Huangxiangjie committed Nov 26, 2024
1 parent 77176f5 commit 28e2c64
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/SmartThings/matter-sensor/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ local TEMP_BOUND_RECEIVED = "__temp_bound_received"
local TEMP_MIN = "__temp_min"
local TEMP_MAX = "__temp_max"

local HUE_MANUFACTURER_ID = 0x100B
-- HUE-0x100B, MultiIR-0x1477
local NOT_SUPPORT_BATTERY_PERCENT_REMAINING_VID = {0x100B, 0x1477}

local function get_field_for_endpoint(device, field, endpoint)
return device:get_field(string.format("%s_%d", field, endpoint))
Expand Down Expand Up @@ -88,11 +89,20 @@ local function set_boolean_device_type_per_endpoint(driver, device)
end
end

local function battery_device_not_support_battery_percent_remaining(device)
for i = 1, #NOT_SUPPORT_BATTERY_PERCENT_REMAINING_VID do
if device.manufacturer_info.vendor_id == NOT_SUPPORT_BATTERY_PERCENT_REMAINING_VID[i] then
return false
end
end
return true
end

local function supports_battery_percentage_remaining(device)
local battery_eps = device:get_endpoints(clusters.PowerSource.ID,
{feature_bitmap = clusters.PowerSource.types.PowerSourceFeature.BATTERY})
-- Hue devices support the PowerSource cluster but don't support reporting battery percentage remaining
if #battery_eps > 0 and device.manufacturer_info.vendor_id ~= HUE_MANUFACTURER_ID then
if #battery_eps > 0 and battery_device_not_support_battery_percent_remaining(device) then
return true
end
return false
Expand Down

0 comments on commit 28e2c64

Please sign in to comment.