Skip to content

Aeotec Home Energy Meter Gen8#1981

Merged
greens merged 17 commits into
SmartThingsCommunity:mainfrom
iot-holding:add-aeotec-home-energy-meter-gen8
Jul 8, 2025
Merged

Aeotec Home Energy Meter Gen8#1981
greens merged 17 commits into
SmartThingsCommunity:mainfrom
iot-holding:add-aeotec-home-energy-meter-gen8

Conversation

@mh-zwave

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

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Mar 6, 2025

Copy link
Copy Markdown

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions

github-actions Bot commented Mar 6, 2025

Copy link
Copy Markdown

Channel deleted.

@github-actions

github-actions Bot commented Mar 6, 2025

Copy link
Copy Markdown

Test Results

   67 files  +  1    443 suites  +23   0s ⏱️ ±0s
2 273 tests +121  2 273 ✅ +121  0 💤 ±0  0 ❌ ±0 
3 907 runs  +234  3 907 ✅ +234  0 💤 ±0  0 ❌ ±0 

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

This pull request removes 4 and adds 125 tests. Note that renamed tests count towards both.
Operational state should generate correct messages
Test battery alert handler
closed contact events
open contact events
Battery level report should be handled
Battery percentage report should be handled (button)
Battery percentage report should be handled (motion illuminance)
Capability command setFanMode should be handled
Capability command setPercent should be handled
Capability off command switch off should be handled : dp 1
Capability off command switch off should be handled : dp 2
Capability off command switch off should be handled : dp 3
Capability off command switch off should be handled : dp 4
Capability off command switch off should be handled : dp 5
…

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Mar 6, 2025

Copy link
Copy Markdown

File Coverage
All files 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-electric-meter/src/preferences.lua 97%
/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/aeotec-home-energy-meter-gen8/3-phase/init.lua 97%
/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/init.lua 96%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against b93df6a

@lelandblue

Copy link
Copy Markdown
Contributor

Hey @Brianj94 - Tagging you for your awareness :)

productId: 0x0001
deviceProfileName: base-electric-meter
- id: "0x0371/0x0003/0x0033" #HEM Gen8 1 Phase EU
deviceLabel: Aeotec Home Engery Meter Gen8 Consumption

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 "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
Copy Markdown
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: No newline at end of file

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.

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

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.

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@greens greens left a comment

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.

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

@lelandblue

Copy link
Copy Markdown
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

greens commented Mar 26, 2025

Copy link
Copy Markdown
Contributor
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
Copy Markdown
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

@greens

greens commented May 12, 2025

Copy link
Copy Markdown
Contributor

We'd prefer the original set of preferences included when this was first submitted. Some of the new preferences added, especially the bitmasks, don't make a ton of sense when presented in our preferences UI.

@mh-zwave

Copy link
Copy Markdown
Contributor Author

I’ve removed some of the parameters. For those we still consider important, I’ve restricted the minimum and maximum values more tightly than what the device technically supports. I believe this is a good compromise and can be represented more effectively in your preference UI.

@mh-zwave mh-zwave requested a review from greens May 22, 2025 09:31
options:
0: "Disable"
1: "Enable"
default: 0

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 preference will most likely lead to problems, since we don't support reporting preference values from the device back up to the UI (two-way preferences).

If the user resets the preference values to the default (i.e. sets this value to "Enable"), the UI will still display the old values, and not the defaults that are actually set on the device.

max: 7200
default: 7200
- name: lockConfig
title: "252. Enable/disable lock config"

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 has the same problem as the reset preference

there's no way to communicate that setting a preference value has failed, which can lead to a bad experience

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.

Does what I said here make sense?

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.

So should I also remove the initially added preferences? However, these are really important because they allow the user to define the threshold values for reporting.

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.

Just the lock preference, I think. If the user locks the preferences, our UI can't reflect that.

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.

Ah ok, got it. I removed the lock preference.

@mh-zwave

Copy link
Copy Markdown
Contributor Author

Alright, I'll remove the newly added preferences again. Is it an issue that we set the reporting interval for power consumption to 5 minutes to ensure the powerConsumption report always provides a current value? Or could this cause problems for the hub?

@greens

greens commented May 28, 2025

Copy link
Copy Markdown
Contributor

@mh-zwave 5 minutes is okay.

@greens greens merged commit 1b1e49e into SmartThingsCommunity:main Jul 8, 2025
12 checks passed
greens added a commit that referenced this pull request Jul 15, 2025
greens added a commit that referenced this pull request Jul 15, 2025
greens added a commit that referenced this pull request Jul 15, 2025
greens added a commit that referenced this pull request Jul 15, 2025
greens added a commit that referenced this pull request Jul 15, 2025
daveylib-abb pushed a commit to daveylib-abb/SmartThingsEdgeDrivers that referenced this pull request Sep 1, 2025
* Aeotec Home Energy Meter Gen8 init

* Add missing Configuration import

* add missing device import

* fix review comments

- add copyright to source files
- add missing tests
- fix typos
- consolidated fingerprints
- fix line indentations
- rework meter_report_handler function

* remove unused imports

* update copyright year

* remove powerConsumptionReport capability from production child device profile

* add missing Parameters

* change deivce for power consumption report in meter report handler

* add doConfigure lifecycle

- add test for doConfigure lifecycle

* fix line indentation

* Update preferences

* Remove preferences

* Remove lock preference

---------

Co-authored-by: Alissa Dornbos <79465613+lelandblue@users.noreply.github.com>
daveylib-abb pushed a commit to daveylib-abb/SmartThingsEdgeDrivers that referenced this pull request Sep 1, 2025
greens added a commit that referenced this pull request Jan 12, 2026
greens added a commit that referenced this pull request Feb 20, 2026
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.

4 participants