Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.09k stars 1.68k forks source link

Schneider Electric PowerTag #7975

Closed OsteHovel closed 1 year ago

OsteHovel commented 3 years ago

Information about the device + link

Schneider Electric PowerTag Monoconnect 63A 1P+N top position

This is energy sensor utilizing Zigbee 3 Green Power

https://www.se.com/ww/en/product/A9MEM1521/energy-sensor%2C-powertag-monoconnect-63a-1p%2Bn-top-position/

data/database.db entry of the device

This gets added during pairing, but it actually does not really pair completely more info below

{
  "id": 3,
  "type": "GreenPower",
  "ieeeAddr": "0x00000000e20765cb",
  "nwkAddr": 26059,
  "manufId": null,
  "modelId": "GreenPower_254",
  "epList": [
    242
  ],
  "endpoints": {
    "242": {
      "epId": 242,
      "inClusterList": [],
      "outClusterList": [],
      "clusters": {},
      "binds": [],
      "configuredReportings": [],
      "meta": {}
    }
  },
  "interviewCompleted": true,
  "meta": {},
  "lastSeen": 1625428765211
}
Info Info
OS Windows
Zigbee2mqtt Latest on master branch
Zigbee-herdsman Latest on master branch
Cordinator CC2531
Channel 15
Network key 0c9f45818f14a953d0993f2304015e10

I have tried with both using a Philips Hue Light strip and using a IKEA E1746 TRADFRI signal repeater

Utilizing the Philips Hue Light strip the light strip does not reply to the channel request sent out by the PowerTag. By utilizing a IKEA signal repeater that actually replies to the channel requests and gets it on the correct channel and sending out a commissioning notification, see Channel request and configuration.pcapng.

I had to do some changes to Zigbee-herdsman to get it actually decode the packet correctly buffaloZcl.ts - Added a check for key present during payload

private readGdpFrame(options: TsType.Options): Gdp | {raw: Buffer} | Record<string, never> {
    // Commisioning
    if (options.payload.commandID === 224) {
        const deviceID = this.readUInt8();
        const options1 = this.readUInt8();
        const extendedOptions = this.readUInt8();

        const gdpKeyPresent = (extendedOptions & 0x20) != 0;
        if (gdpKeyPresent) {
            return {
                deviceID: deviceID,
                options: options1,
                extendedOptions: extendedOptions,
                securityKey: this.readBuffer(16),
                keyMic: this.readUInt32(),
                outgoingCounter: this.readUInt32(),
            };
        } else {
            return {
                deviceID: deviceID,
                options: options1,
                extendedOptions: extendedOptions,
                securityKey: null,
                keyMic: null,
                outgoingCounter: this.readUInt32(),
            };
        }
    } else if (this.position != this.buffer.length) {
        return {raw: this.buffer.slice(this.position)};
    } else {
        return {};
    }
}

greenPower.ts

public async onZclGreenPowerData(dataPayload: AdapterEvents.ZclDataPayload): Promise<void> {
    if (dataPayload.frame.Payload.commandID === 224 && typeof dataPayload.address === 'number') {

        const keyPresent = (dataPayload.frame.Payload.extendedOptions & 0x20) != 0;
        if (keyPresent) {
            const key = this.encryptSecurityKey(
                dataPayload.frame.Payload.srcID, dataPayload.frame.Payload.commandFrame.securityKey
            );

            const payload = {
                options: 0b1_1_100_10_1_0_10_0_1_000,
                srcID: dataPayload.frame.Payload.srcID,
                sinkGroupID: this.adapter.greenPowerGroup,
                deviceID: dataPayload.frame.Payload.commandFrame.deviceID,
                frameCounter: dataPayload.frame.Payload.commandFrame.outgoingCounter,
                gpdKey: [...key],
            };

            const frame = Zcl.ZclFrame.create(
                Zcl.FrameType.SPECIFIC, Zcl.Direction.SERVER_TO_CLIENT, true,
                null, ZclTransactionSequenceNumber.next(), 'pairing', 33, payload
            );

            await this.adapter.sendZclFrameToAll(242, frame, 242);
        } else {
            // Key not present security
            const key = Buffer.from([0xc9, 0x79, 0xd5, 0x22, 0x9c, 0xb9, 0xe9,
                0xd2, 0x8d, 0x5d, 0xa6, 0x99, 0xf8, 0xca, 0x02, 0x97]);

            const options = 0b1_1_010_11_1_1_10_0_1_000;
            const payload = {
                options: options,
                srcID: dataPayload.frame.Payload.srcID,
                sinkGroupID: this.adapter.greenPowerGroup,
                deviceID: dataPayload.frame.Payload.commandFrame.deviceID,
                frameCounter: dataPayload.frame.Payload.commandFrame.outgoingCounter,
                gpdKey: [...key],
            };

            const frame = Zcl.ZclFrame.create(
                Zcl.FrameType.SPECIFIC, Zcl.Direction.SERVER_TO_CLIENT, true,
                null, ZclTransactionSequenceNumber.next(), 'pairing', 33, payload
            );

            await this.adapter.sendZclFrameToAll(242, frame, 242);
        }

        const eventData: GreenPowerDeviceJoinedPayload = {
            sourceID: dataPayload.frame.Payload.srcID,
            deviceID: dataPayload.frame.Payload.commandFrame.deviceID,
            networkAddress: dataPayload.address,
        };

        this.emit(GreenPowerEvents.deviceJoined, eventData);
    }
}

I have flipped around with the options to try to get any response.

PowerTag Commissioning.pcapng is a captured when the PowerTag is being commissioned by a Schnieder Electric Acti 9 Smartlink SI B

Zigbee2mqtt pairing.pcapng is a capture of what happening when I am trying to pair with zigbee2mqtt I am thinking it is because the IKEA Signal Repeater (and for that matter the Philips Hue) is repeating the Green Power using protocol version 2 instead of 3, or I am just formatting the packets wrong.

smulle48 commented 2 years ago

I assume this it what you mean,, I very unfamiliar with zigbee2mqtt

debug

@filips is this because of an different modelID ?

filips commented 2 years ago

The modelID should not have much influence.. I have successfully paired a R9M42, so I would expect the R9M41 to be the same, as it it just the mirrored version as far as I can tell.

When looking at the debug output I do notice something weird: the encryption key provided by the powertag is pure 0's. I haven't seen that before, and it makes me wonder whether there is some issue with the Proxy used. I usually allow pairing only to one router in the Z2M web interface, so I can be sure which one I'm pairing to. Could you confirm how you pair the powertags, and maybe try to do it the same way for both, only allowing pairing to a specific router?

edenhome commented 2 years ago

The modelID should not have much influence.. I have successfully paired a R9M42, so I would expect the R9M41 to be the same, as it it just the mirrored version as far as I can tell.

When looking at the debug output I do notice something weird: the encryption key provided by the powertag is pure 0's. I haven't seen that before, and it makes me wonder whether there is some issue with the Proxy used. I usually allow pairing only to one router in the Z2M web interface, so I can be sure which one I'm pairing to. Could you confirm how you pair the powertags, and maybe try to do it the same way for both, only allowing pairing to a specific router?

Agree R9M42 and R9M41 should be the same. It was located next to the sonoff cordinator when i first tried,, now it has been removed from the switchboard. I tried to pair with just one router,,, tried both a HUE and a Nordtronic, result always the same

when conecting power is blink red, then after paring it will keep blink orange,,, and after a while it go back to fast red blink,,, same as it never recived an ack

Inrego commented 2 years ago

I'm in the process of changing over to a slae.sh dongle. The PowerTags are working great! I'm having some issues with some light bulbs on this dongle, but that's unrelated to this.

Telk0 commented 2 years ago

Which powertag you have? i have R9M22 1P+N and its not putting out any data.

Inrego commented 2 years ago

I ended up having just the PowerTags paired with my slae.sh dongle, and then the rest of my zigbee network on the Conbee (due to some of my lights not working on the slae.sh dongle).

It was working great, for a week or so. Then I stopped getting any data from the PowerTags. I tried resetting them, and they won't even pair with the slae.sh dongle. I had one of them paired to my conbee for a while (about an hour) and then it stopped working. The other one would pair, but not send any data. It's all a bit unstable, really.

Inrego commented 2 years ago

Now they're both paired to my conbee dongle, but getting no data from any of them

smulle48 commented 2 years ago

@filips I've had it running for a while, but I'm getting some unexpected behavior.

I've attached the log file from zigbee2mqtt.

Though I get an mitt message about every 5 second, the value from the PowerTag does not update every 5 seconds. I can't seem to find a clear pattern on how/when it update the value.

Is that anything you have experienced?

log2.txt

verydrunk commented 2 years ago

I would like to beg for some help, I have R9M20 and R9M40 and a sonoff z3.0 usb dongle plus. And I can't get none of them to pair. Do I need something else? IKEA repeater, lamp what ever? Please help. I'm getting desperate as Schneider desided to ruin the little function the old app still had.

filips commented 2 years ago

I would like to beg for some help, I have R9M20 and R9M40 and a sonoff z3.0 usb dongle plus. And I can't get none of them to pair. Do I need something else? IKEA repeater, lamp what ever? Please help. I'm getting desperate as Schneider desided to ruin the little function the old app still had.

To pair a green power device you need a device to act as a green power proxy, which is always powered. It can be a repeater, lamp or smart plug. I have had it working with both IKEA and Philips devices, but when I used an IKEA repeater i stopped getting some updates after a week or so. For the past two months I have been using a Philips Hue smart plug instead, which I have had no issues with.

filips commented 2 years ago

@filips I've had it running for a while, but I'm getting some unexpected behavior.

I've attached the log file from zigbee2mqtt.

Though I get an mitt message about every 5 second, the value from the PowerTag does not update every 5 seconds. I can't seem to find a clear pattern on how/when it update the value.

Is that anything you have experienced?

log2.txt

It looks like the values are not changing from message to message, I'm specifically looking at the "energy" field. I have experienced this in some form, where the powertag is just continuously retransmitting the last message, because it is not receiving the ACK package that it needs to get. You will probably be able to see the powertag led flashing red rapidly when this happens.

What device are you using as the proxy for pairing? I have had good success with philips devices, and somewhat less with IKEA repeaters. I've had something like what you're seeing happen after a week or so with an ikea repeater.

smulle48 commented 2 years ago

@filips I've had it running for a while, but I'm getting some unexpected behavior.

I've attached the log file from zigbee2mqtt.

Though I get an mitt message about every 5 second, the value from the PowerTag does not update every 5 seconds. I can't seem to find a clear pattern on how/when it update the value.

Is that anything you have experienced?

log2.txt

It looks like the values are not changing from message to message, I'm specifically looking at the "energy" field. I have experienced this in some form, where the powertag is just continuously retransmitting the last message, because it is not receiving the ACK package that it needs to get. You will probably be able to see the powertag led flashing red rapidly when this happens.

What device are you using as the proxy for pairing? I have had good success with philips devices, and somewhat less with IKEA repeaters. I've had something like what you're seeing happen after a week or so with an ikea repeater.

Unfortunately I only got ikea bulbs.

The weird thing is that if I take power(w) and run it through a Reimann in HA, I get the correct readings

verydrunk commented 2 years ago

Still having trouble with R9M20/M40 tried connecting to Hue bulb LWA001, Hue Smart Plug ED8597, Hue GU10 LCT003. I have a buttload of different hue lights and guess i continue to switch router. But any help would be appreciated

Info 2022-07-09 12:00:15Device '0x00000000e2032ba2' joined Info 2022-07-09 12:00:15MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"0x00000000e2032ba2","ieee_address":"0x00000000e2032ba2"},"type":"device_joined"}' Info 2022-07-09 12:00:15Successfully interviewed '0x00000000e2032ba2', device has successfully been paired Warning 2022-07-09 12:00:15Device '0x00000000e2032ba2' with Zigbee model 'GreenPower_84' and manufacturer name 'undefined' is NOT supported, please follow https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html Info 2022-07-09 12:00:15MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"definition":null,"friendly_name":"0x00000000e2032ba2","ieee_address":"0x00000000e2032ba2","status":"successful","supported":false},"type":"device_interview"}' Debug 2022-07-09 12:00:15Received Zigbee message from '0x00000000e2032ba2', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"applicationInfo":0,"deviceID":94,"extendedOptions":188,"gpdClientClusters":{"data":[],"type":"Buffer"},"gpdCommandIdList":{"data":[],"type":"Buffer"},"gpdServerClusters":{"data":[],"type":"Buffer"},"keyMic":0,"manufacturerID":0,"modelID":0,"numClientClusters":0,"numGdpCommands":0,"numServerClusters":0,"options":216,"outgoingCounter":1420269332,"securityKey":{"data":[86,193,29,233,43,52,15,108,72,216,253,245,131,102,39,143],"type":"Buffer"}},"commandID":224,"frameCounter":7183602,"gppGddLink":157,"gppNwkAddr":35576,"options":2616,"payloadSize":44,"srcID":3791858594}' from endpoint 242 with groupID 0 Warning 2022-07-09 12:00:15Received message from unsupported device with Zigbee model 'GreenPower_84' and manufacturer name 'undefined' Warning 2022-07-09 12:00:15Please see: https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html

BDSmmadsen commented 2 years ago

Any updates?

Inrego commented 2 years ago

I would like to beg for some help, I have R9M20 and R9M40 and a sonoff z3.0 usb dongle plus. And I can't get none of them to pair. Do I need something else? IKEA repeater, lamp what ever? Please help. I'm getting desperate as Schneider desided to ruin the little function the old app still had.

To pair a green power device you need a device to act as a green power proxy, which is always powered. It can be a repeater, lamp or smart plug. I have had it working with both IKEA and Philips devices, but when I used an IKEA repeater i stopped getting some updates after a week or so. For the past two months I have been using a Philips Hue smart plug instead, which I have had no issues with.

After your suggestion, I finally seem to have a working, stable setup. Here's my setup to actually get it working: My primary ZigBee network is on a ConBee II (some of my lights were very unstable on the slae.sh dongle). I added a slae.sh dongle to run a seperate zigbee network for these PowerTags. I added a single Philips Hue bulb to this network (the PowerTags didn't work without this step).

So yeah, I'm running 2 seperate zigbee networks. One for the PowerTags, and one for everything else. The PowerTags don't work properly on the ConBee II coordinator, and some other devices don't work properly on the slae.sh coordinator. So I guess that's the only way, unfortunately. With that said, it's not that big of a hassle since it just works now.

ciedema commented 2 years ago

I was able to connect to a Clipsal 4RCBEM2B, which I think is an Australian version of an R9M60

ciedema commented 2 years ago

There are a bunch of Attributes that say what Type, Model and 'brand' Power Tag etc. It would be cool to have this added to the converter as well. How hard is to determine the model from these attributes and have it show as such in the Z2M dashboard?

Screenshot 2022-09-07 111047

Screenshot 2022-09-07 113201

Screenshot 2022-09-07 113403

ciedema commented 2 years ago

I've had a bit of mess about with this tonight, using an external converter. I have it telling me the the Make (in Australia they are sold as Clipsal Devices ) and Model and a few other things that show up in the Zigbee Packets.

Screenshot 2022-09-07 221253

It would be great if I can update these values from the data returned, but my Z2M experience is about ten days old, so I don't understand every that can be called to update values. It's easy enough to understand once the relevant class or function is found, but it takes a bit to find it. Screenshot 2022-09-07 223351

ciedema commented 2 years ago

Okay, I've done some work on a custom converter for these, with the eventual idea of incorporating back into zigbee-herdsman-converters. I'm not sure I'm on the right track here @filips and @Koenkk. I've only been at these converters for ten days and am far from understanding the nuance of how everything fits together. Is changing the Model Id okay after pairing? Is there a better way to do what I have done? I'm happy to continue on this path if I'm on the right track. It means the correct device type is reported in the Devices List, and we can make the attributes relevant to 3 and single-phase devices (see screenshot below).

const fz = {...require('zigbee-herdsman-converters/converters/fromZigbee'), legacy: require('zigbee-herdsman-converters/lib/legacy').fromZigbee };
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const constants = require('zigbee-herdsman-converters/lib/constants');
const extend = require('zigbee-herdsman-converters/lib/extend');
const utils = require('zigbee-herdsman-converters/lib/utils');
const e = exposes.presets;
const ea = exposes.access;

const ep1 = [
    e.power(),
    e.power_apparent(),
    exposes.numeric('power_phase_a', ea.STATE).withUnit('W').withDescription('Instantaneous measured power on phase A'),
    e.power_factor(),
    e.energy(),
    exposes.numeric('energy_phase_a', ea.STATE).withUnit('kWh').withDescription('Sum of consumed energy on phase A'),
    e.ac_frequency(),
    exposes.numeric('voltage_phase_a', ea.STATE).withUnit('V').withDescription('Measured electrical potential value on phase A'),
    exposes.numeric('current_phase_a', ea.STATE).withUnit('A').withDescription('Instantaneous measured electrical current on phase A'),
    exposes.text('manufacturerName', ea.STATE),
    exposes.text('modelID', ea.STATE),
    exposes.text('brand', ea.STATE),
    exposes.text('power_tag_type', ea.STATE),
    exposes.text('hwVersion', ea.STATE),
];

const ep3 = [
    e.power(),
    e.power_apparent(),
    exposes.numeric('power_phase_a', ea.STATE).withUnit('W').withDescription('Instantaneous measured power on phase A'),
    exposes.numeric('power_phase_b', ea.STATE).withUnit('W').withDescription('Instantaneous measured power on phase B'),
    exposes.numeric('power_phase_c', ea.STATE).withUnit('W').withDescription('Instantaneous measured power on phase C'),
    e.power_factor(),
    e.energy(),
    exposes.numeric('energy_phase_a', ea.STATE).withUnit('kWh').withDescription('Sum of consumed energy on phase A'),
    exposes.numeric('energy_phase_b', ea.STATE).withUnit('kWh').withDescription('Sum of consumed energy on phase B'),
    exposes.numeric('energy_phase_c', ea.STATE).withUnit('kWh').withDescription('Sum of consumed energy on phase C'),
    e.ac_frequency(),
    exposes.numeric('voltage_phase_a', ea.STATE).withUnit('V').withDescription('Measured electrical potential value on phase A'),
    exposes.numeric('voltage_phase_b', ea.STATE).withUnit('V').withDescription('Measured electrical potential value on phase B'),
    exposes.numeric('voltage_phase_c', ea.STATE).withUnit('V').withDescription('Measured electrical potential value on phase C'),
    exposes.numeric('voltage_phase_ab', ea.STATE)
        .withUnit('V').withDescription('Measured electrical potential value between phase A and B'),
    exposes.numeric('voltage_phase_bc', ea.STATE)
        .withUnit('V').withDescription('Measured electrical potential value between phase B and C'),
    exposes.numeric('voltage_phase_ca', ea.STATE)
        .withUnit('V').withDescription('Measured electrical potential value between phase C and A'),
    exposes.numeric('current_phase_a', ea.STATE)
        .withUnit('A').withDescription('Instantaneous measured electrical current on phase A'),
    exposes.numeric('current_phase_b', ea.STATE)
        .withUnit('A').withDescription('Instantaneous measured electrical current on phase B'),
    exposes.numeric('current_phase_c', ea.STATE)
        .withUnit('A').withDescription('Instantaneous measured electrical current on phase C'),
    exposes.text('manufacturerName', ea.STATE),
    exposes.text('modelID', ea.STATE),
    exposes.text('brand', ea.STATE),
    exposes.text('power_tag_type', ea.STATE),
    exposes.text('hwVersion', ea.STATE),
];

const fzLocal = {
    schneider_powertag: {
        cluster: 'greenPower',
        type: ['commandNotification', 'commandCommisioningNotification'],
        convert: async (model, msg, publish, options, meta) => {
            if (msg.type !== 'commandNotification') {
                return;
            }

            const commandID = msg.data.commandID;
            if (utils.hasAlreadyProcessedMessage(msg, msg.data.frameCounter, `${msg.device.ieeeAddr}_${commandID}`)) return;

            const rxAfterTx = (msg.data.options & (1<<11));
            const ret = {};

            switch (commandID) {
            case 0xA1: {
                const attr = msg.data.commandFrame.attributes;
                const clusterID = msg.data.commandFrame.clusterID;

                switch (clusterID) {
                case 0: {
                    if (attr.hasOwnProperty('manufacturerName')) {
                        ret['manufacturerName']= attr['manufacturerName'];
                        meta.device.manufacturerName=attr['manufacturerName'];
                        meta.device.save();                        
                    }

                    if (attr.hasOwnProperty('modelId')) {
                        ret['modelID']= attr['modelId'];
                        meta.device.modelID=attr['modelId'];
                        meta.device.save();
                    }

                    if (attr.hasOwnProperty('manufacturerCode')) {
                        ret['manufacturerCode']= attr['manufacturerCode'];
                        meta.device.manufacturerCode=attr['manufacturerCode'];
                        meta.device.manufId=attr['manufacturerCode'];
                        meta.device.save();
                    }

                    if (attr.hasOwnProperty('57352')) {
                        ret['brand']= attr['57352'];
                    }

                    if (attr.hasOwnProperty('57353')) {
                        ret['power_tag_type']= attr['57353'];
                    }

                    if (attr.hasOwnProperty('57345')) {
                        ret['hwVersion']= attr['57345'];
                        meta.device.hwVersion=attr['57345'];
                        meta.device.save();
                    }

                    break;
                }

                case 2820: { // haElectricalMeasurement
                    const acCurrentDivisor = attr['acCurrentDivisor'];
                    const acVoltageDivisor = attr['acVoltageDivisor'];
                    const acFrequencyDivisor = attr['acFrequencyDivisor'];
                    const powerDivisor = attr['powerDivisor'];

                    if (attr.hasOwnProperty('rmsVoltage')) {
                        ret['voltage_phase_a'] = attr['rmsVoltage'] / acVoltageDivisor;
                    }

                    if (attr.hasOwnProperty('rmsVoltagePhB')) {
                        ret['voltage_phase_b'] = attr['rmsVoltagePhB'] / acVoltageDivisor;
                    }

                    if (attr.hasOwnProperty('rmsVoltagePhC')) {
                        ret['voltage_phase_c'] = attr['rmsVoltagePhC'] / acVoltageDivisor;
                    }

                    if (attr.hasOwnProperty('19200')) {
                        ret['voltage_phase_ab'] = attr['19200'] / acVoltageDivisor;
                    }

                    if (attr.hasOwnProperty('19456')) {
                        ret['voltage_phase_bc'] = attr['19456'] / acVoltageDivisor;
                    }

                    if (attr.hasOwnProperty('19712')) {
                        ret['voltage_phase_ca'] = attr['19712'] / acVoltageDivisor;
                    }

                    if (attr.hasOwnProperty('rmsCurrent')) {
                        ret['current_phase_a'] = attr['rmsCurrent'] / acCurrentDivisor;
                    }

                    if (attr.hasOwnProperty('rmsCurrentPhB')) {
                        ret['current_phase_b'] = attr['rmsCurrentPhB'] / acCurrentDivisor;
                    }

                    if (attr.hasOwnProperty('rmsCurrentPhC')) {
                        ret['current_phase_c'] = attr['rmsCurrentPhC'] / acCurrentDivisor;
                    }

                    if (attr.hasOwnProperty('totalActivePower')) {
                        ret['power'] = attr['totalActivePower'] * 1000 / powerDivisor;
                    }

                    if (attr.hasOwnProperty('totalApparentPower')) {
                        ret['power_apparent'] = attr['totalApparentPower'] * 1000 / powerDivisor;
                    }

                    if (attr.hasOwnProperty('acFrequency')) {
                        ret['ac_frequency'] = attr['acFrequency'] / acFrequencyDivisor;
                    }

                    if (attr.hasOwnProperty('activePower')) {
                        ret['power_phase_a'] = attr['activePower'] * 1000 / powerDivisor;
                    }

                    if (attr.hasOwnProperty('activePowerPhB')) {
                        ret['power_phase_b'] = attr['activePowerPhB'] * 1000 / powerDivisor;
                    }

                    if (attr.hasOwnProperty('activePowerPhC')) {
                        ret['power_phase_c'] = attr['activePowerPhC'] * 1000 / powerDivisor;
                    }
                    break;
                }
                case 1794: { // seMetering
                    const divisor = attr['divisor'];

                    if (attr.hasOwnProperty('currentSummDelivered')) {
                        const val = attr['currentSummDelivered'];
                        ret['energy'] = ((parseInt(val[0]) << 32) + parseInt(val[1])) / divisor;
                    }

                    if (attr.hasOwnProperty('16652')) {
                        const val = attr['16652'];
                        ret['energy_phase_a'] = ((parseInt(val[0]) << 32) + parseInt(val[1])) / divisor;
                    }

                    if (attr.hasOwnProperty('16908')) {
                        const val = attr['16908'];
                        ret['energy_phase_b'] = ((parseInt(val[0]) << 32) + parseInt(val[1])) / divisor;
                    }

                    if (attr.hasOwnProperty('17164')) {
                        const val = attr['17164'];
                        ret['energy_phase_c'] = ((parseInt(val[0]) << 32) + parseInt(val[1])) / divisor;
                    }

                    if (attr.hasOwnProperty('powerFactor')) {
                        ret['power_factor'] = attr['powerFactor'];
                    }

                    break;
                }
                }

                break;
            }
            case 0xA3:
                // Should handle this cluster as well
                break;
            }

            if (rxAfterTx) {
                // Send Schneider specific ACK to make PowerTag happy
                const networkParameters = await msg.device.zh.constructor.adapter.getNetworkParameters();
                const payload = {
                    options: 0b000,
                    tempMaster: msg.data.gppNwkAddr,
                    tempMasterTx: networkParameters.channel - 11,
                    srcID: msg.data.srcID,
                    gpdCmd: 0xFE,
                    gpdPayload: {
                        commandID: 0xFE,
                        buffer: new Uint8Array(1) // I hope it's zero initialised
                    },
                };

                await msg.endpoint.commandResponse('greenPower', 'response', payload,
                    {
                        srcEndpoint: 242,
                        disableDefaultResponse: true,
                    });
            }

            return ret;
        },
    },
};

const definition = [
    {
        fingerprint: [{modelID: 'GreenPower_254', ieeeAddr: /^0x00000000e.......$/}],
        model: 'Powertag',
        vendor: 'Schneider Electric',
        description: 'PowerTag power sensor',
        fromZigbee: [fzLocal.schneider_powertag],
        toZigbee: [],
        exposes: ep3,
    },
    {
        zigbeeModel: ['A9MEM1570'],
        model: 'A9MEM1570',
        vendor: 'Schneider Electric',
        description: 'PowerTag Flex 63A 3P+N',
        fromZigbee: [fzLocal.schneider_powertag],
        toZigbee: [],
        exposes: ep3,
    },

    {
        zigbeeModel: ['4RCBEM2'],
        model: '4RCBEM2',
        vendor: 'Clipsal',
        description: 'Powertag Flex 1P+N 63A',
        fromZigbee: [fzLocal.schneider_powertag],
        toZigbee: [],
        exposes: ep1,
    }
];
module.exports = definition;

Screenshot 2022-09-08 153033

Screenshot 2022-09-08 153655

Inrego commented 2 years ago

I don't have much to add, but clicking the model id on device list links to the documentation page. Does changing the model id also change this link? Or could the link be the same across different models?

ciedema commented 2 years ago

I'm happy enough to create the relevant documentation pages.

Inrego commented 2 years ago

But if model is something you extract from the device, and that becomes part of the documentation page URL, then you will have broken links for any model you didn't create documentation page for yet.

Tbh, I don't really know what makes most sense. That there's only documentation page for tested devices? But I'd say it's not great that untested devices pair, but the link to their documentation page are broken.

Again, if the URL to the documentation page can be specified rather than auto generated from model id alone, then it should be possible to make a documentation page for untested devices with some general information.

Inrego commented 2 years ago

On another note, I think info about compatibility issues should be added to the documentation pages. There's these that I know of (since I ran into them myself):

ciedema commented 2 years ago

But if model is something you extract from the device, and that becomes part of the documentation page URL, then you will have broken links for any model you didn't create documentation page for yet.

AFIAK if the model is extracted from the device, you'll need to code the converter appropriately anyway, there aren't that many of them, and the pages are rinse and repeat. A few of the tags are fairly similar for our purposes so you could group them together. For example the Resi9 R9M60, Acti9 A9MEM1560, and Clipsal 4RCBEM2 are pretty much the same device ie an F63 1P+N and the tag I think will report this for all three. No reason you couldn't combine these into one thing.

I've got a few more tags on the way - this time Schneider Resi9's, far cheaper to import than buy AU Clipsal branded ones, I'll see if the data coming from them is consistent with the Clipsal one I have. I'm going to keep an eye on the prices, and if I see some Acti 9's going cheap, I'll grab one or two of those.

  • Issues with Conbee II dongles

That's a bit of an odd one. I put a sniffer firmware on my old Conbee II, and it sees the GPD packets just fine but wouldn't pair, - who knows?

  • Needs to pair to a router, pairing directly with the coordinator doesn't work

This applies to any ZGP device.

I'm all a bit new to this. My JS is pretty rusty, and Wireshark is something I toy with from time to time. Fair wack of knowledge acquisition as I put the work in on this.

filips commented 2 years ago

The issue with the Conbee dongles is that they wrap the green power frames in a non-standard format before we can read them out. If i remember correctly, this leads to Zigbee2MQTT having to use the length of the frame to distinguish between a commissioning frame, and an attribute report, for instance. I don't own a conbee dongle, so I haven't tried - only looked at the code, and tried to understand issues people were facing. It generally works with the simpler ZGP devices that are not RX capable, this is where the powertags differ significantly.

When you compare it to regular zigbee devices, we have the model info before pairing the device, whereas the powertags as you have seen will only show which model it is after the entire commissioning and pairing sequence has completed. Thus I presume the way you're doing it could be just fine.

I agree that it would be desirable to have some of the quirks related to the powertag devices listed in the documentation. I have only had it working for less than a week with an IKEA router - the Philips Hue plug I'm using currently has been working flawlessly for many months.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

ciedema commented 2 years ago

As an FYI.

I'm waiting on some more powertags to arrive so I can test my current convertor and then add it to main code base. A quick question - apparently you can write device names to these. Would anyone who has a Schnieder Hub be able to sniff these?

ghogberg commented 2 years ago

I have the following setup right now: Conbee2 w/firmware 26780700 Philips Hue Power Plug 929003050601 w/firmware 1.93.6 Zigbee2Mqtt version 1.28.0-1 installed as add-on Home Assistant 2022.10.3 Supervisor 2022.10.0 Operating System 9.2 Frontend 20221010.0 - latest

Powertags are a range of R9M21, R9M41, A9MEM1541, A9MEM1521

I do also have one of the slae.sh dongles flashed with the latest "coordinator" firmware, but it seems to give me the same situation.

Based on the posts from @ciedema I've also put a file "side by side" with the /config/zigbee2mqtt/configuration.yaml and called it "schneider_electric.js" with his configuration and done the following to the configuration.yaml file: external_converters:

I'm attaching my log, as by my (very n00bish knowledge) of zigbee, it seems that the powertags aren't receiving any ACKs, and hence goes back to the "fast red blinking"... Unsure what I can do different as I have others who seem to have the same setup as myself (but maybe a different firmware on the Philips Hue Power Plug) and are successfully making it work... I used to run these tags with the Schneider Wiser gateway eer31800, but since the app got so bad and limited, I wanted to use the power to gather all this data myself. log.txt

Telk0 commented 2 years ago

Hello,

How do i convert this modelid to the converter? debug 2022-10-13 15:18:22: Received Zigbee message from '0x00000000e2021c01', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"applicationInfo":3,"deviceID":254,"extendedOptions":131,"gpdClientClusters":{"data":[],"type":"Buffer"},"gpdCommandIdList":{"data":[],"type":"Buffer"},"gpdServerClusters":{"data":[],"type":"Buffer"},"keyMic":0,"manufacturerID":4190,"modelID":17242,"numClientClusters":0,"numGdpCommands":0,"numServerClusters":0,"options":231,"outgoingCounter":3925082,"securityKey":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"}},"commandID":224,"frameCounter":10,"gppGddLink":187,"gppNwkAddr":2352,"options":2056,"payloadSize":12,"srcID":3791789057}' from endpoint 242 with groupID 0

Its a R9M42. Im using channel 15, It joins as unsupported in Z2M. When i see your converter @ciedema you just write the clipsal number.

changed the converter to this: zigbeeModel: ['R9M42'], model: 'R9M42', vendor: 'Schneider Electric', description: 'PowerTag 63A 3P+N', fromZigbee: [fzLocal.schneider_powertag], toZigbee: [], exposes: ep3,

But its not working. What am i doing wrong :S

verydrunk commented 2 years ago

U need to connect it to for ex. a hue power plug, for me it needed to be very close to the object when pairing.

To reconnect a R9 model u need to remove it from ur setup and make it powerless for 10 sek, when flashing yellow u start looking for new devices and accept pairing only with the power plug.

Telk0 commented 2 years ago

@verydrunk I have a hue plug 30-50 cm within the R9 i pair through. but it said no converter for the powertag. How to translate the modelid: 17242 ?

I have it showing up in my Z2M but as unsupported & no data and model is just "Powertag power sensor" it dosent recognize modelid

Do my converter look correct?

verydrunk commented 2 years ago

@Telk0 No, u need a lot extra if u compare with the shneider_electric.js

I have the same modell and had to remove and pair 3-4 times before i got at least one of them in to the system. Type should be "GreenPower_254" when successful.

I use the standard schneider_electric.js and at last it works great, but the headache...

Telk0 commented 2 years ago

I have All from ciedema converter only thing i changed is the part i pasted... So its crap to pair it correctly.. Is it stable when paired

verydrunk commented 2 years ago

Yes it was for me, One is still connected to a hue bulb, but i dont now witch, and still working great. The plug is about 3 meter/9.5 feet and updating every 30sec perfectly on 3 tags (2 different models)

Telk0 commented 2 years ago

For some reason after deleting from ip modul and turning it off.. I cant get the power tags into yellow/orange pair mode.

Telk0 commented 2 years ago

Seems i have same issue as @ghogberg. @verydrunk @ciedema @filips Any idea what this issue is?

verydrunk commented 2 years ago

I have no idé, had mine to the ip gateway to until the new firmware stopped allowed local connection hence I need to push the button and generate a new key once a week.

Maybe a new firmware to the tags that we don't know about...

I use the sonoff usb ZigBee gateway with the second latest firmware flashed.

brianmansfeldt commented 2 years ago

I’m running Z2M with Deconz 2.

First I added 1 Philips Hue Smartplug with GPZ. Then 1 powertag (R9M42) It worked perfect for 6-7 days.

Then I added a second powertag, but now both my powertag loses connection from time to time. Typically after 10 mins to 3 hours. How to debug why ?

Now I’m trying to remove the second powertag again- and only use 1 powertag, it seems like it’s running perfect again now. But it’s frustrating that a second powertag is a problem.

Anyone with a solution on this problem ?

Inrego commented 2 years ago

@brianmansfeldt did you make sure the power tags paired to that Philips hue plug? When starting pairing in Z2M, did you leave it default for all devices? Or did you choose the hue plug to only allow pairing with that device?

brianmansfeldt commented 2 years ago

@brianmansfeldt did you make sure the power tags paired to that Philips hue plug? When starting pairing in Z2M, did you leave it default for all devices? Or did you choose the hue plug to only allow pairing with that device?

I have tried both ways, permit join from Philips hue, and from all. I’m not using this z2m network to other devices yet. So there is only the Philips hue plug and Powertag on.

I have removed the second powertag now, and it’s still works perfect. The problem is only when I add the second, then both powertags losing connection.

Right now I’m running on Deconz 2 - but I also have a Sonoff I can try. But is there a way to debug and see why the powertags losing connection?

Inrego commented 2 years ago

Ah, I guess when you say Deconz 2, you mean ConBee II? Deconz is software (like Z2M). It is well known that ConBee has issues with these Powertags. Your Sonoff dongle should work better.

I run two ZigBee networks. My main one on my ConBee stick, and then a single hue bulb and two Powertags on another stick that is similar to the Sonoff. This is only because I have some light bulbs that don't work good on other than ConBee. Otherwise I'd just drop the ConBee.

brianmansfeldt commented 2 years ago

Ah, I guess when you say Deconz 2, you mean ConBee II? Deconz is software (like Z2M). It is well known that ConBee has issues with these Powertags. Your Sonoff dongle should work better.

I run two ZigBee networks. My main one on my ConBee stick, and then a single hue bulb and two Powertags on another stick that is similar to the Sonoff. This is only because I have some light bulbs that don't work good on other than ConBee. Otherwise I'd just drop the ConBee.

Deconz, yes sorry mean Conbee 2. I’m trying to switch with my Sonoff. But I still need the Philips Hue plug for GPZ ? Or can Sonoff Dongle Plus run GPZ ?

brianmansfeldt commented 2 years ago

Ah, I guess when you say Deconz 2, you mean ConBee II? Deconz is software (like Z2M). It is well known that ConBee has issues with these Powertags. Your Sonoff dongle should work better.

I run two ZigBee networks. My main one on my ConBee stick, and then a single hue bulb and two Powertags on another stick that is similar to the Sonoff. This is only because I have some light bulbs that don't work good on other than ConBee. Otherwise I'd just drop the ConBee.

What Zigbee channels are you using for two networks ? I’m also running my main network on ZHA channel 25. An my Z2M on channel 15.

Inrego commented 2 years ago

Ah, I guess when you say Deconz 2, you mean ConBee II? Deconz is software (like Z2M). It is well known that ConBee has issues with these Powertags. Your Sonoff dongle should work better.

I run two ZigBee networks. My main one on my ConBee stick, and then a single hue bulb and two Powertags on another stick that is similar to the Sonoff. This is only because I have some light bulbs that don't work good on other than ConBee. Otherwise I'd just drop the ConBee.

Deconz, yes sorry mean Conbee 2. I’m trying to switch with my Sonoff. But I still need the Philips Hue plug for GPZ ? Or can Sonoff Dongle Plus run GPZ ?

Yes you still need the Philips hue.

Telk0 commented 2 years ago

Can any say why log says that my hue plug have no greenpower converter?

Debug 2022-10-16 12:56:47Received Zigbee message from '0x00000000e201e884', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"applicationInfo":3,"deviceID":254,"extendedOptions":131,"gpdClientClusters":{"data":[],"type":"Buffer"},"gpdCommandIdList":{"data":[],"type":"Buffer"},"gpdServerClusters":{"data":[],"type":"Buffer"},"keyMic":0,"manufacturerID":4190,"modelID":17244,"numClientClusters":0,"numGdpCommands":0,"numServerClusters":0,"options":231,"outgoingCounter":13733376,"securityKey":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"}},"commandID":224,"frameCounter":32,"gppGddLink":229,"gppNwkAddr":58350,"options":2056,"payloadSize":12,"srcID":3791775876}' from endpoint 242 with groupID 0 Debug 2022-10-16 12:56:48Received Zigbee message from '0x00000000e201e884', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"applicationInfo":3,"deviceID":254,"extendedOptions":131,"gpdClientClusters":{"data":[],"type":"Buffer"},"gpdCommandIdList":{"data":[],"type":"Buffer"},"gpdServerClusters":{"data":[],"type":"Buffer"},"keyMic":0,"manufacturerID":4190,"modelID":17244,"numClientClusters":0,"numGdpCommands":0,"numServerClusters":0,"options":231,"outgoingCounter":13733377,"securityKey":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"}},"commandID":224,"frameCounter":33,"gppGddLink":229,"gppNwkAddr":58350,"options":2056,"payloadSize":12,"srcID":3791775876}' from endpoint 242 with groupID 0 Debug 2022-10-16 12:56:49Received Zigbee message from '0x00000000e201e884', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"applicationInfo":3,"deviceID":254,"extendedOptions":131,"gpdClientClusters":{"data":[],"type":"Buffer"},"gpdCommandIdList":{"data":[],"type":"Buffer"},"gpdServerClusters":{"data":[],"type":"Buffer"},"keyMic":0,"manufacturerID":4190,"modelID":17244,"numClientClusters":0,"numGdpCommands":0,"numServerClusters":0,"options":231,"outgoingCounter":13733378,"securityKey":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"}},"commandID":224,"frameCounter":34,"gppGddLink":229,"gppNwkAddr":58350,"options":2056,"payloadSize":12,"srcID":3791775876}' from endpoint 242 with groupID 0 Debug 2022-10-16 12:56:50Received Zigbee message from '0x00000000e201e884', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"applicationInfo":3,"deviceID":254,"extendedOptions":131,"gpdClientClusters":{"data":[],"type":"Buffer"},"gpdCommandIdList":{"data":[],"type":"Buffer"},"gpdServerClusters":{"data":[],"type":"Buffer"},"keyMic":0,"manufacturerID":4190,"modelID":17244,"numClientClusters":0,"numGdpCommands":0,"numServerClusters":0,"options":231,"outgoingCounter":13733379,"securityKey":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"}},"commandID":224,"frameCounter":35,"gppGddLink":229,"gppNwkAddr":58350,"options":2056,"payloadSize":12,"srcID":3791775876}' from endpoint 242 with groupID 0 Debug 2022-10-16 12:56:51Received Zigbee message from '0x00000000e201e884', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"applicationInfo":3,"deviceID":254,"extendedOptions":131,"gpdClientClusters":{"data":[],"type":"Buffer"},"gpdCommandIdList":{"data":[],"type":"Buffer"},"gpdServerClusters":{"data":[],"type":"Buffer"},"keyMic":0,"manufacturerID":4190,"modelID":17244,"numClientClusters":0,"numGdpCommands":0,"numServerClusters":0,"options":231,"outgoingCounter":13733380,"securityKey":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"}},"commandID":224,"frameCounter":36,"gppGddLink":229,"gppNwkAddr":58350,"options":2056,"payloadSize":12,"srcID":3791775876}' from endpoint 242 with groupID 0 Debug 2022-10-16 12:56:52Received Zigbee message from '0x00000000e201e884', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"applicationInfo":3,"deviceID":254,"extendedOptions":131,"gpdClientClusters":{"data":[],"type":"Buffer"},"gpdCommandIdList":{"data":[],"type":"Buffer"},"gpdServerClusters":{"data":[],"type":"Buffer"},"keyMic":0,"manufacturerID":4190,"modelID":17244,"numClientClusters":0,"numGdpCommands":0,"numServerClusters":0,"options":231,"outgoingCounter":13733381,"securityKey":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"}},"commandID":224,"frameCounter":37,"gppGddLink":229,"gppNwkAddr":58350,"options":2056,"payloadSize":12,"srcID":3791775876}' from endpoint 242 with groupID 0 Debug 2022-10-16 12:56:54Received Zigbee message from 'Hue plug', type 'commandCommisioningNotification', cluster 'greenPower', data '{"commandFrame":{"raw":{"data":[238,227,230,208,169,26,131],"type":"Buffer"}},"commandID":30,"frameCounter":13915378,"gppGddLink":230,"gppNwkAddr":58350,"options":2616,"payloadSize":95,"srcID":3791776658}' from endpoint 242 with groupID 0 Debug 2022-10-16 12:56:54No converter available for '929003050601' with cluster 'greenPower' and type 'commandCommisioningNotification' and data '{"commandFrame":{"raw":{"data":[238,227,230,208,169,26,131],"type":"Buffer"}},"commandID":30,"frameCounter":13915378,"gppGddLink":230,"gppNwkAddr":58350,"options":2616,"payloadSize":95,"srcID":3791776658}'

brianmansfeldt commented 2 years ago

Ah, I guess when you say Deconz 2, you mean ConBee II? Deconz is software (like Z2M). It is well known that ConBee has issues with these Powertags. Your Sonoff dongle should work better. I run two ZigBee networks. My main one on my ConBee stick, and then a single hue bulb and two Powertags on another stick that is similar to the Sonoff. This is only because I have some light bulbs that don't work good on other than ConBee. Otherwise I'd just drop the ConBee.

Deconz, yes sorry mean Conbee 2. I’m trying to switch with my Sonoff. But I still need the Philips Hue plug for GPZ ? Or can Sonoff Dongle Plus run GPZ ?

Yes you still need the Philips hue.

Sonoff 3.0 Dongle Plus works perfect 😉

Inrego commented 2 years ago

Ah, I guess when you say Deconz 2, you mean ConBee II? Deconz is software (like Z2M). It is well known that ConBee has issues with these Powertags. Your Sonoff dongle should work better.

I run two ZigBee networks. My main one on my ConBee stick, and then a single hue bulb and two Powertags on another stick that is similar to the Sonoff. This is only because I have some light bulbs that don't work good on other than ConBee. Otherwise I'd just drop the ConBee.

What Zigbee channels are you using for two networks ? I’m also running my main network on ZHA channel 25. An my Z2M on channel 15.

My Powertag network is channel 21. And my main network on 25

Telk0 commented 2 years ago

Is this greenpower coding (commisioning) etc. Still only in dev branch?

ciedema commented 2 years ago

Is this greenpower coding (commisioning) etc. Still only in dev branch?

The commissioning and a generic power tag are in production.

Telk0 commented 2 years ago

Is this greenpower coding (commisioning) etc. Still only in dev branch?

The commissioning and a generic power tag are in production.

Can you explain why i cannot commision the R9M42 then ? Im using Sonoff P dongle via Hue Smart Plug (Proxy) It shows up in Z2M but never stops blinking orange.