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

[Eve] Improve Eve Energy support #940

Merged

Conversation

Timac
Copy link
Contributor

@Timac Timac commented Aug 31, 2023

These changes improve the Eve Energy support

  • A subdriver has been implemented
  • It implements the switch, powerMeter, energyMeter and powerConsumptionReport capabilities
  • It supports the refresh capability
  • It reads with a timer each minute the current Watt and Watt Accumulated values from custom attributes
  • The powerMeter and energyMeter values are updated each values or on a refresh
  • A powerConsumptionReport is sent each 10 minutes by comparing the previous Watt Accumulated value with the current Watt Accumulated value

Timac added 6 commits August 31, 2023 11:08
- A subdriver has been implemented
- It implements the switch, powerMeter, energyMeter and powerConsumptionReport capabilities
- It supports the refresh capability
- It reads with a timer each minute the current Watt and Watt Accumulated values from custom attributes
- The powerMeter and energyMeter values are updated each values or on a refresh
- A powerConsumptionReport is sent each 10 minutes by comparing the previous Watt Accumulated value with the current Watt Accumulated value
@github-actions
Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link

github-actions bot commented Aug 31, 2023

Channel deleted.

@github-actions
Copy link

github-actions bot commented Aug 31, 2023

Test Results

     52 files     341 suites   0s ⏱️
1 618 tests 1 618 ✔️ 0 💤 0
2 803 runs  2 803 ✔️ 0 💤 0

Results for commit c80f08e.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Aug 31, 2023

File Coverage
All files 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/eve-energy/init.lua 91%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against c80f08e

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.

We'd like to see some tests written for these changes.

@z-michel z-michel requested a review from ctowns August 31, 2023 15:29
@Timac
Copy link
Contributor Author

Timac commented Aug 31, 2023

We'd like to see some tests written for these changes.

I added the file test_eve_energy.lua with really basic tests. At the moment, I don’t know how to properly test the custom attributes on the custom cluster. Maybe @greens you might have some ideas?

The function requestData is called each minute with the timer to read the custom attribute on the custom cluster:

local PRIVATE_CLUSTER_ID = 0x130AFC01

local PRIVATE_ATTR_ID_WATT = 0x130A000A
local PRIVATE_ATTR_ID_WATT_ACCUMULATED = 0x130A000B

[…]

local function requestData(device)
  -- Update the on/off status
  device:send(clusters.OnOff.attributes.OnOff:read(device))

  -- Update the Watt usage
  device:send(cluster_base.read(device, 0x01, PRIVATE_CLUSTER_ID, PRIVATE_ATTR_ID_WATT, nil))

  -- Update the energy consumption
  device:send(cluster_base.read(device, 0x01, PRIVATE_CLUSTER_ID, PRIVATE_ATTR_ID_WATT_ACCUMULATED, nil))
end

@greens
Copy link
Contributor

greens commented Aug 31, 2023

@Timac I believe you'd want to use

test.timer.__create_and_queue_test_time_advance_timer(60, "interval")

Similarly to how it is used in this zigbee test: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/zigbee-contact/src/test/test_zigbee_contact.lua#L141

And then, you'd want to queue up expect_sends passing reads the exact way you've constructed them in the driver.

… triggers the function requestData(). This function will read the standard and custom attributes from the device.
@Timac
Copy link
Contributor Author

Timac commented Sep 1, 2023

@Timac I believe you'd want to use

test.timer.__create_and_queue_test_time_advance_timer(60, "interval")

Similarly to how it is used in this zigbee test: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/zigbee-contact/src/test/test_zigbee_contact.lua#L141

And then, you'd want to queue up expect_sends passing reads the exact way you've constructed them in the driver.

That worked. Thanks a lot!

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.

looks good

@lelandblue lelandblue merged commit 4b2c4de into SmartThingsCommunity:main Sep 25, 2023
11 checks passed
@Timac Timac deleted the feature/eve-energy-powerconsumption branch November 2, 2023 09:10
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