Zigbee double socket picked up as single socket in Zigbee2MQTT

I’m putting this here in case anyone else has a similar issue. I fixed this using information found in these forums and using perplexity.

In my case i purchased a
Melery UK Zigbee Smart Wall Socket Tuya Power Monitor Outlet the model was listed as WS013-Zigbee.

I run HAOS and have Z2M (Zigbee2MQTT) loaded as an add on.

Before i continue, i knew this model was not listed as a supported Z2M device.

Anyway, when it arrived, it did pair with Z"M, however it ws identified as a TS011F_plug_1, which is a single outlet device. I found i could only control the left hand socket via Z2M.

Anyway the solution, which sounded scary at first, is to create an external convertor. Perplexity gave me this as a suitable external convertor.

export default {
zigbeeModel: [‘TS011F’],
model: ‘TS011F_plug_1’,
vendor: ‘_TZ3210_bep7ccew’,
description: ‘Dual outlet with power monitoring’,
extend: [
m.deviceEndpoints({ endpoints: { left: 1, right: 2 } }), // :one:
m.onOff({
powerOnBehavior: false,
endpointNames: [‘left’, ‘right’] // :two:
}),
m.electricityMeter()
],
meta: {
multiEndpoint: true,
multiEndpointSkip: [‘current’, ‘voltage’, ‘power’, ‘energy’] // :three:
},
};

The next bits are specific to using HAOS and Z2M as an addon, this was based on a topic from Arnen, Z2MQTT External converter - Configuration / Zigbee - Home Assistant Community

You will need SSH and file editor add on installed. (credit to Arnen for this bit).

  • open Terminal
    • cd homeassistant/
    • cd zigbee2mqtt/
    • mkdir external_converters
    • cd external_converters
    • touch convertor.js
  • open File editor
    • paste your convertor code
    • save your convertor code

I then restated Z2M and ran another interview. It now exposes both the left and right hand states.

One thing to note, i don’t have any other TS011F_plug_1 devices except for another Melery one. I i did have other devices this may have impacted them, and the solution is to target the IEEE Address instead of the model (i believe)

Great work, now create a PR in the zigbee-herdsman-convertors GitHub :wink:

i expanded a little, if intrested,…
save this to zigbee2mqtt/external_converters/tz3210_bep7ccew.js

import * as m from 'zigbee-herdsman-converters/lib/modernExtend';
import * as tuya from 'zigbee-herdsman-converters/lib/tuya';
import fz from 'zigbee-herdsman-converters/converters/fromZigbee';
import tz from 'zigbee-herdsman-converters/converters/toZigbee';
import * as reporting from 'zigbee-herdsman-converters/lib/reporting';

export default {

    fingerprint: [
        {
            modelID: 'TS011F',
            manufacturerName: '_TZ3210_bep7ccew',
        },
    ],

    zigbeeModel: ['TS011F'],
    model: 'MG-GPO01',
    vendor: 'MakeGood',
    description: 'Double Zigbee power point',
    icon: 'https://www.zigbee2mqtt.io/images/devices/MG-AUZG01.png',

    extend: [
        m.deviceEndpoints({endpoints: {right: 1, left: 2}}),
        m.identify(),
        tuya.modernExtend.tuyaOnOff({
            endpoints: ['right', 'left'],
            powerOutageMemory: true,
            indicatorMode: true,
            childLock: true,
            onOffCountdown: true,
            electricalMeasurements: true,
        }),
    ],

    fromZigbee: [fz.identify, fz.on_off, fz.electrical_measurement, fz.metering, fz.power_on_behavior],
    toZigbee: [tz.on_off, tz.power_on_behavior, tz.electrical_measurement_power],

    configure: async (device, coordinatorEndpoint) => {
        const endpoint1 = device.getEndpoint(1);
        const endpoint2 = device.getEndpoint(2);

        await tuya.configureMagicPacket(device, coordinatorEndpoint);

        await reporting.bind(endpoint1, coordinatorEndpoint, [
            'genOnOff',
            'haElectricalMeasurement',
            'seMetering',
        ]);
        await reporting.onOff(endpoint1);
        await reporting.rmsVoltage(endpoint1, {min: 5, max: 3600, change: 1});
        await reporting.rmsCurrent(endpoint1, {min: 5, max: 3600, change: 1});
        await reporting.activePower(endpoint1, {min: 5, max: 3600, change: 1});
        await reporting.currentSummDelivered(endpoint1, {min: 5, max: 3600, change: 257});

        await reporting.bind(endpoint2, coordinatorEndpoint, ['genOnOff']);

        endpoint1.saveClusterAttributeKeyValue('haElectricalMeasurement', {
            acCurrentDivisor: 1000,
            acCurrentMultiplier: 1,
            acPowerDivisor: 1,
            acPowerMultiplier: 1,
            acVoltageDivisor: 1,
            acVoltageMultiplier: 1,
        });

        endpoint1.saveClusterAttributeKeyValue('seMetering', {
            divisor: 100,
            multiplier: 1,
        });

        device.save();
    },

    meta: {
        multiEndpoint: true,
        multiEndpointSkip: ['power', 'current', 'voltage', 'energy'],
        tuyaDatapoints: [
            [1, 'state_right', tuya.valueConverter.onOff],
            [2, 'state_left', tuya.valueConverter.onOff],
            [9, 'countdown_right', tuya.valueConverter.raw],
            [10, 'countdown_left', tuya.valueConverter.raw],
            [17, 'energy', tuya.valueConverter.divideBy100],
            [18, 'current', tuya.valueConverter.divideBy1000],
            [19, 'power', tuya.valueConverter.raw],
            [20, 'voltage', tuya.valueConverter.divideBy10],
            [26, 'fault', tuya.valueConverter.trueFalse0],
            [27, 'power_outage_memory', tuya.valueConverterBasic.lookup({'off': 0, 'on': 1, 'restore': 2})],
            [28, 'indicator_mode', tuya.valueConverterBasic.lookup({'off': 0, 'off/on': 1, 'on/off': 2, 'on': 3})],
            [29, 'child_lock', tuya.valueConverter.lockUnlock],
        ],
    },
};

Excellent… thanks. I did have to do the following after I pasted in the code.

In your Zigbee2MQTT configuration.yaml: Add the following at the bottom

external_converters:

  • external_converters/tz3210_bep7ccew.js

✅ Restart Zigbee2MQTT
✅ Re-interview the device in Z2M web UI

Just wondering, I have 2 more of these sockets, will they just work as the current one installed or will I have to add additional external converters?

If they are the same model then no, it will pick them up automatically.