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

Improve reporting E2206 #8060

Merged
merged 11 commits into from
Oct 12, 2024
34 changes: 31 additions & 3 deletions src/devices/ikea.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {Zcl} from 'zigbee-herdsman';

import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import * as exposes from '../lib/exposes';
import * as reporting from '../lib/reporting';
import {
addCustomClusterManuSpecificIkeaAirPurifier,
addCustomClusterManuSpecificIkeaUnknown,
Expand Down Expand Up @@ -30,7 +33,6 @@ import {
commandsWindowCovering,
deviceAddCustomCluster,
deviceEndpoints,
electricityMeter,
humidity,
iasZoneAlarm,
identify,
Expand All @@ -45,6 +47,9 @@ import {
import * as ota from '../lib/ota';
import {DefinitionWithExtend} from '../lib/types';

const e = exposes.presets;
const ea = exposes.access;

const definitions: DefinitionWithExtend[] = [
// #region light
// lights naming convention: type, light capabilities, form, diffuser type, brightness
Expand Down Expand Up @@ -602,7 +607,30 @@ const definitions: DefinitionWithExtend[] = [
model: 'E2206',
vendor: 'IKEA',
description: 'INSPELNING smart plug',
extend: [addCustomClusterManuSpecificIkeaUnknown(), onOff(), identify(), ikeaOta(), electricityMeter()],
extend: [addCustomClusterManuSpecificIkeaUnknown(), onOff(), identify(), ikeaOta()],
fromZigbee: [fz.electrical_measurement, fz.metering],
toZigbee: [tz.electrical_measurement_power, tz.acvoltage, tz.accurrent, tz.currentsummdelivered],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['haElectricalMeasurement', 'seMetering']);
// Enable reporting of powerDivisor, needs to change dynamically with the amount of power
// For details, see: https://github.com/Koenkk/zigbee2mqtt/issues/23961#issuecomment-2366733453
await endpoint.configureReporting('haElectricalMeasurement', [
Rembock marked this conversation as resolved.
Show resolved Hide resolved
{ attribute: 'acPowerDivisor', minimumReportInterval: 5, maximumReportInterval: 3600, reportableChange: 1 }
]);
await reporting.readEletricalMeasurementMultiplierDivisors(endpoint);
await reporting.readMeteringMultiplierDivisor(endpoint);
await reporting.rmsVoltage(endpoint, { min: 10, change: 10 }); // Report Voltage every 10 seconds - Min change of 1V
await reporting.rmsCurrent(endpoint, { min: 10, change: 10 }); // Report Ampere every 10 seconds - Min change of 0,01A
await reporting.activePower(endpoint, { min: 10, change: 10 }); // Report Watt every 10 seconds - Min change of 1W
await reporting.currentSummDelivered(endpoint, { min: 300 }); // Report kWh every 5min
},
exposes: [
e.power().withAccess(ea.STATE_GET),
e.voltage().withAccess(ea.STATE_GET),
e.current().withAccess(ea.STATE_GET),
e.energy().withAccess(ea.STATE_GET)
],
},
// #endregion on/off controls
// #region blinds
Expand Down
Loading