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

electricityMeter can only use the default settings #8395

Open
script0803 opened this issue Nov 29, 2024 · 7 comments
Open

electricityMeter can only use the default settings #8395

script0803 opened this issue Nov 29, 2024 · 7 comments

Comments

@script0803
Copy link
Contributor

extend: [identify(), onOff({"powerOnBehavior":false}), electricityMeter({
threePhase: true,
producedEnergy: true,
acFrequency: true,
powerFactor: true,
})],

I used this code and applied it to my external converter, but none of these extra settings worked

@Koenkk
Copy link
Owner

Koenkk commented Nov 29, 2024

Are you using the latest z2m?

@script0803
Copy link
Contributor Author

Oh, I just updated my z2m and it works now, thank you very much.

In addition, I have another problem. I used

await endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {
acPowerMultiplier: 1, acPowerDivisor: 1});

in the converter to change my power unit from kw to w, but it doesn't seem to work now.

@Koenkk
Copy link
Owner

Koenkk commented Dec 5, 2024

To set the divisor with modern extend, see

extend: [light({configureReporting: true}), electricityMeter({current: {divisor: 1000}, voltage: {divisor: 10}, power: {divisor: 10}})],

@script0803
Copy link
Contributor Author

Hi, @Koenkk

I tried these methods, but none of them worked. It seems that the divisor defined in my device will force overwrite what I set in the converter.

So can I choose not to change the divisor but change the unit from w to kw?

image
const {electricityMeter} = require('zigbee-herdsman-converters/lib/modernExtend');
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const e = exposes.presets;

const definition = {
    zigbeeModel: ['SPM01X001'],
    model: 'SPM01X00111',
    vendor: 'BITUO TECHNIK',
    description: 'Automatically generated definition',
    configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ['haElectricalMeasurement', 'seMetering']);
            await reporting.readMeteringMultiplierDivisor(endpoint);
            await endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {
            acPowerMultiplier: 1, acPowerDivisor: 1,
        });
    },
    extend: [electricityMeter({fzMetering: fz.metering,
        acFrequency: true,
        powerFactor: true,
        configureReporting: false,
        producedEnergy: true,
        power: {divisor: 1, multiplier: 1},
        })],
    meta: {},
    exposes: [
        e.power_apparent()
    ],
};

module.exports = definition;

@script0803
Copy link
Contributor Author

Could it be that after the devices are paired successfully, the converter changes the divisor internally, but after the converter
is configured, the device actively reports all the information about the multiplier and divisor again, so the data changed by the converter is overwritten again?

image

@Koenkk
Copy link
Owner

Koenkk commented Dec 10, 2024

the device actively reports all the information about the multiplier and divisor again, so the data changed by the converter is overwritten again?

Yes! You can confirm that by looking at your data/database.db file. But isn't this caused by await reporting.readMeteringMultiplierDivisor(endpoint); ? This reads the divisor from the device.

@script0803
Copy link
Contributor Author

script0803 commented Dec 11, 2024

await reporting.readMeteringMultiplierDivisor(endpoint); is used to read the factor in the meter, not the coefficients in ElectricalMeasurement. These two should be independent?

And if I use await reporting.readEletricalMeasurementMultiplierDivisors(endpoint); to get the factor, then it should be read attribute in the data, not the current report attribute.

So I can only choose to write a converter to force EletricalMeasurementMultiplierDivisors to 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants