Skip to content

WWSTCERT-10559/10562/10565/10568 add driver to frient EMI devices#2730

Merged
greens merged 14 commits intoSmartThingsCommunity:mainfrom
marcintyminski:Add-support-to-frient-EMIs
Mar 9, 2026
Merged

WWSTCERT-10559/10562/10565/10568 add driver to frient EMI devices#2730
greens merged 14 commits intoSmartThingsCommunity:mainfrom
marcintyminski:Add-support-to-frient-EMIs

Conversation

@marcintyminski
Copy link
Copy Markdown
Contributor

Check all that apply

Type of Change

  • WWST Certification Request
    • If this is your first time contributing code:
      • I have reviewed the README.md file
      • I have reviewed the CODE_OF_CONDUCT.md file
      • I have signed the CLA
    • I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • New feature
  • Refactor

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have verified my changes by testing with a device or have communicated a plan for testing
  • I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Description of Change

Summary of Completed Tests

@github-actions
Copy link
Copy Markdown

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 26, 2026

Channel deleted.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 26, 2026

Test Results

   72 files    492 suites   0s ⏱️
2 684 tests 2 684 ✅ 0 💤 0 ❌
4 545 runs  4 545 ✅ 0 💤 0 ❌

Results for commit 00100ba.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 26, 2026

File Coverage
All files 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/configurations.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/frient/init.lua 93%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 00100ba

@marcintyminski marcintyminski changed the title add driver add driver to frient EMI devices Jan 27, 2026
@KKlimczukS KKlimczukS requested a review from greens February 4, 2026 10:43
@greens greens changed the title add driver to frient EMI devices WWSTCERT-10228/10231/10234 add driver to frient EMI devices Feb 5, 2026
@greens greens changed the title WWSTCERT-10228/10231/10234 add driver to frient EMI devices WWSTCERT-10225/10228/10231/10234 add driver to frient EMI devices Feb 5, 2026
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/can_handle.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/fingerprints.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/can_handle.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/sub_drivers.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/fingerprints.yml
raw_value = raw_value * multiplier / divisor * 1000

-- The result is already in watts, no need to multiply by 1000
device:emit_component_event(device.profile.components['main'], capabilities.powerMeter.power({ value = raw_value, unit = "W" }))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

when emitting for the main component, you can just use device:emit_event

Copy link
Copy Markdown
Contributor

@greens greens Feb 5, 2026

Choose a reason for hiding this comment

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

Also this seems identical to the defaults except for the default value, which you could set elsewhere (like in added) with

device:set_field(zigbee_constants.SIMPLE_METERING_DIVISOR_KEY, SIMPLE_METERING_DEFAULT_DIVISOR)

instead of overriding the default behavior

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For some reason the configuration of attribute does not work without this handler here

Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/EMIZB-151/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/utils.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/init.lua
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/init.lua Outdated
Comment on lines +118 to +131
local function instantaneous_demand_handler(driver, device, value, zb_rx)
local raw_value = value.value
--- demand = demand received * Multipler/Divisor
local multiplier = device:get_field(zigbee_constants.SIMPLE_METERING_MULTIPLIER_KEY) or 1
local divisor = device:get_field(zigbee_constants.SIMPLE_METERING_DIVISOR_KEY) or SIMPLE_METERING_DEFAULT_DIVISOR
if raw_value < -8388607 or raw_value >= 8388607 then
raw_value = 0
end

raw_value = raw_value * multiplier / divisor * 1000

local raw_value_watts = raw_value
device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, capabilities.powerMeter.power({ value = raw_value_watts, unit = "W" }))
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This also seems functionally the same as the default behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The device sometimes sends weird values, so we added a guard to ignore these values

device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, capabilities.powerMeter.power({ value = raw_value_watts, unit = "W" }))
end

local function energy_meter_handler(driver, device, value, zb_rx)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's different between this handler and the sub-driver's version?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is the same story as with instantaneous_demand_handler. If we delete the function from subdriver the configuration od CurrentSummationDelivered stops working and it only refreshes when we refresh it manually.

Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/init.lua Outdated
@KKlimczukS KKlimczukS requested a review from greens February 9, 2026 08:51
Comment on lines +52 to +53
device:send(SimpleMetering.attributes.Divisor:read(device))
device:send(SimpleMetering.attributes.Multiplier:read(device))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i believe these will be read as part of the default refresh handlers, since they're configured attributes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They are not included in refresh here. If we delete them, it will never read them and it will use the default value we assigned to zigbee_constants.SIMPLE_METERING_MULTIPLIER_KEY and zigbee_constants.SIMPLE_METERING_DIVISOR_KEY

Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/can_handle.lua Outdated
Comment thread drivers/SmartThings/zigbee-power-meter/src/frient/fingerprints.lua Outdated
@KKlimczukS KKlimczukS requested a review from greens March 6, 2026 09:33
@greens greens changed the title WWSTCERT-10225/10228/10231/10234 add driver to frient EMI devices WWSTCERT-10559/10562/10565/10568 add driver to frient EMI devices Mar 9, 2026
@greens greens merged commit b82b7e1 into SmartThingsCommunity:main Mar 9, 2026
12 checks passed
cjswedes pushed a commit that referenced this pull request Mar 25, 2026
)

* add driver

* removed unused variables

* Changes according to pr comments

* More changes based on pr comments

* date changes

* Requested changes to categories in profiles and updated tests

* fix conflict

* remove extra closing parenthesis
ctowns pushed a commit that referenced this pull request Apr 1, 2026
)

* add driver

* removed unused variables

* Changes according to pr comments

* More changes based on pr comments

* date changes

* Requested changes to categories in profiles and updated tests

* fix conflict

* remove extra closing parenthesis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants