WWSTCERT-10559/10562/10565/10568 add driver to frient EMI devices#2730
Conversation
|
Duplicate profile check: Passed - no duplicate profiles detected. |
|
Channel deleted. |
Test Results 72 files 492 suites 0s ⏱️ Results for commit 00100ba. ♻️ This comment has been updated with latest results. |
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 00100ba |
| 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" })) |
There was a problem hiding this comment.
when emitting for the main component, you can just use device:emit_event
There was a problem hiding this comment.
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
There was a problem hiding this comment.
For some reason the configuration of attribute does not work without this handler here
| 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 |
There was a problem hiding this comment.
This also seems functionally the same as the default behavior.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
what's different between this handler and the sub-driver's version?
There was a problem hiding this comment.
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.
| device:send(SimpleMetering.attributes.Divisor:read(device)) | ||
| device:send(SimpleMetering.attributes.Multiplier:read(device)) |
There was a problem hiding this comment.
i believe these will be read as part of the default refresh handlers, since they're configured attributes.
There was a problem hiding this comment.
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
Check all that apply
Type of Change
Checklist
Description of Change
Summary of Completed Tests