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

Added fields for DC power metering. #7390

Merged
merged 4 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/converters/fromZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ const converters1 = {
{key: 'rmsVoltagePhB', name: 'voltage_phase_b', factor: 'acVoltage'},
{key: 'rmsVoltagePhC', name: 'voltage_phase_c', factor: 'acVoltage'},
{key: 'acFrequency', name: 'ac_frequency', factor: 'acFrequency'},
{key: 'dcPower', name: 'power', factor: 'dcPower'},
{key: 'dcCurrent', name: 'current', factor: 'dcCurrent'},
{key: 'dcVoltage', name: 'voltage', factor: 'dcVoltage'},
];

const payload: KeyValueAny = {};
Expand Down
15 changes: 14 additions & 1 deletion src/devices/custom_devices_diy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ function ptvoAddStandardExposes(endpoint: Zh.Endpoint, expose: Expose[], options
if (endpoint.supportsInputCluster('genPowerCfg')) {
deviceOptions['expose_battery'] = true;
}
if (endpoint.supportsInputCluster('msCO2')) {
expose.push(e.co2().withEndpoint(epName));
deviceOptions['exposed_co2'] = true;
}
if (endpoint.supportsInputCluster('genMultistateInput') || endpoint.supportsOutputCluster('genMultistateInput')) {
deviceOptions['expose_action'] = true;
}
Expand Down Expand Up @@ -276,7 +280,7 @@ const definitions: Definition[] = [
description: 'Multi-functional device',
fromZigbee: [fz.battery, fz.on_off, fz.ptvo_multistate_action, legacy.fz.ptvo_switch_buttons, fz.ptvo_switch_uart,
fz.ptvo_switch_analog_input, fz.brightness, fz.ignore_basic_report, fz.temperature,
fzLocal.humidity2, fzLocal.pressure2, fzLocal.illuminance2],
fzLocal.humidity2, fzLocal.pressure2, fzLocal.illuminance2, fz.electrical_measurement, fz.metering, fz.co2],
toZigbee: [tz.ptvo_switch_trigger, tz.ptvo_switch_uart, tz.ptvo_switch_analog_input, tz.ptvo_switch_light_brightness, tzLocal.ptvo_on_off],
exposes: (device, options) => {
const expose: Expose[] = [];
Expand Down Expand Up @@ -489,6 +493,15 @@ const definitions: Definition[] = [
}
} catch (err) {/* do nothing */}
}
for (const endpoint of device.endpoints) {
if (endpoint.supportsInputCluster('haElectricalMeasurement')) {
endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {dcCurrentDivisor: 1000, dcCurrentMultiplier: 1,
dcPowerDivisor: 10, dcPowerMultiplier: 1, dcVoltageDivisor: 100, dcVoltageMultiplier: 1});
}
if (endpoint.supportsInputCluster('seMetering')) {
endpoint.saveClusterAttributeKeyValue('seMetering', {divisor: 100, multiplier: 1});
}
}
}
},
},
Expand Down