Skip to content

Aeotec Home Energy Meter Gen8 #1981

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

mh-zwave
Copy link
Contributor

@mh-zwave mh-zwave commented Mar 6, 2025

Check all that apply

Type of Change

  • [x ] 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
    • [x ] 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

Copy link

github-actions bot commented Mar 6, 2025

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

github-actions bot commented Mar 6, 2025

Copy link

github-actions bot commented Mar 6, 2025

Test Results

   66 files  ±  0    426 suites  +6   0s ⏱️ ±0s
2 208 tests + 56  2 208 ✅ + 56  0 💤 ±0  0 ❌ ±0 
3 805 runs  +132  3 805 ✅ +132  0 💤 ±0  0 ❌ ±0 

Results for commit e368cad. ± Comparison against base commit 0db6c68.

This pull request removes 2 and adds 58 tests. Note that renamed tests count towards both.
Operational state should generate correct messages
Test battery alert handler
Capability command setFanMode should be handled
Capability command setPercent should be handled
Fan mode reports should generate correct messages
Fan mode sequence reports should generate the appropriate supported modes
Flow reports should generate correct messages
Handle preference: autoReportExp1 (parameter 104) in infoChanged
Handle preference: autoReportExp2 (parameter 105) in infoChanged
Handle preference: autoReportExp3 (parameter 106) in infoChanged
Handle preference: autoReportImp1 (parameter 101) in infoChanged
Handle preference: autoReportImp2 (parameter 102) in infoChanged
…

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Mar 6, 2025

File Coverage
All files 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-electric-meter/src/aeotec-home-energy-meter-gen8/2-phase/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-electric-meter/src/preferences.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-electric-meter/src/aeotec-home-energy-meter-gen8/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-electric-meter/src/aeotec-home-energy-meter-gen8/1-phase/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-electric-meter/src/aeotec-home-energy-meter-gen8/3-phase/init.lua 97%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against e368cad

@lelandblue
Copy link
Contributor

Hey @Brianj94 - Tagging you for your awareness :)

@@ -35,6 +35,36 @@ zwaveManufacturer:
productType: 0x0002
productId: 0x0001
deviceProfileName: base-electric-meter
- id: "0x0371/0x0003/0x0033" #HEM Gen8 1 Phase EU
deviceLabel: Aeotec Home Engery Meter Gen8 Consumption
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe "Engery" is a typo in all of these join names

- id: "0x0371/0x0003/0x0034" # HEM Gen8 3 Phase EU
deviceLabel: Aeotec Home Engery Meter Gen8 Consumption
manufacturerId: 0x0371
productType: 0x0003
Copy link
Contributor

Choose a reason for hiding this comment

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

in general what we've done with other Aeotec devices is consolidated fingerprints by omitting the productType, which you could do here for the 1 and 3 phase meters

version: 1
categories:
- name: CurbPowerMeter
preferences:
Copy link
Contributor

Choose a reason for hiding this comment

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

if there are no preferences, this line can be omitted. same above

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you change back and forth between 2- and 4-space tab widths

local child_device_key = find_hem8_child_device_key_by_endpoint(endpoint);
local child_device = device:get_child_by_parent_assigned_key(child_device_key)

if child_device then
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than repeating yourself here, you could just create a variable like device_to_emit_with that defaults to device and just overwrite it if a child_device is found. Avoids this if statement with the duplicated code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are absolutely right.

Copy link
Contributor

Choose a reason for hiding this comment

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

you should add the common functionality between the sub-drivers to this parent driver here, like the refresh function and the meter_report_handler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have intentionally moved the refresh and meter_report_handler functions to the sub-drivers because they each target different endpoints, which are defined in the sub-drivers. How could I implement this efficiently in the parent driver?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't noticing the differences in the HEM8_DEVICES map. There's still probably a way to do it, but in light of those differences I imagine it's more complicated.

Copy link
Contributor

@greens greens left a comment

Choose a reason for hiding this comment

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

Please add the copyright notice to the top of your source files.

@lelandblue
Copy link
Contributor

Hello @mh-zwave Thank you for your PR. Please review the above comments and address them so that the review can proceed at your nearest opportunity. Thank you.

- add copyright to source files
- add missing tests
- fix typos
- consolidated fingerprints
- fix line indentations
- rework meter_report_handler function
@mh-zwave mh-zwave requested a review from greens March 26, 2025 15:12
@greens
Copy link
Contributor

greens commented Mar 26, 2025

Checking drivers/SmartThings/zwave-electric-meter/src/test/test_aeotec_home_energy_meter_gen8_1_phase.lua 1 warning

    drivers/SmartThings/zwave-electric-meter/src/test/test_aeotec_home_energy_meter_gen8_1_phase.lua:15:7: (W211) unused variable st_utils

Checking drivers/SmartThings/zwave-electric-meter/src/test/test_aeotec_home_energy_meter_gen8_2_phase.lua 1 warning

    drivers/SmartThings/zwave-electric-meter/src/test/test_aeotec_home_energy_meter_gen8_2_phase.lua:15:7: (W211) unused variable st_utils

Checking drivers/SmartThings/zwave-electric-meter/src/test/test_aeotec_home_energy_meter_gen8_3_phase.lua 1 warning

    drivers/SmartThings/zwave-electric-meter/src/test/test_aeotec_home_energy_meter_gen8_3_phase.lua:15:7: (W211) unused variable st_utils

@@ -0,0 +1,190 @@
-- Copyright 2022 SmartThings
Copy link
Contributor

Choose a reason for hiding this comment

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

this year is incorrect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants