Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don‘t merge now]Add device not support battery percent remaining attribute #1783

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

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