Powerplug TS011F meter functionality missing

Bug fix has been merged in the upcoming 2021.12.0 release. So to get everything working fine we need to wait and then update HA then click on “reconfigure device” for each plug

Not sure if it’s only me, but I “imported” the change as a custom quirk and a “reconfigure” was not enough.
I had to go to the “zigbee.db” and remove cached attributes from the “attributes_v7” table.

I guess a re-pairing would achieve the same.

Hi, everybody. With this external converter I got almost 100% of power measurement. Remember to replace or add your specific ‘manufacturerName’:

const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const globalStore = require('zigbee-herdsman-converters/lib/store');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const e = exposes.presets;
const ea = exposes.access;

module.exports = [
{
        fingerprint: [{modelID: 'TS011F', manufacturerName: '_TZ3000_rdtixbnu'}],
        model: 'TS011F_plug',
        description: 'Smart plug (with power monitoring)',
        vendor: 'TuYa',
        fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering, fz.ignore_basic_report, fz.tuya_switch_power_outage_memory],
        toZigbee: [tz.on_off, tz.tuya_switch_power_outage_memory],
        configure: async (device, coordinatorEndpoint, logger) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff', 'haElectricalMeasurement']);
            endpoint.saveClusterAttributeKeyValue('seMetering', {divisor: 100, multiplier: 1});
            endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {
                acVoltageMultiplier: 1, acVoltageDivisor: 1, acCurrentMultiplier: 1, acCurrentDivisor: 1000, acPowerMultiplier: 1,
                acPowerDivisor: 1,
            });
        },
        // This device doesn't support reporting correctly.
        // https://github.com/Koenkk/zigbee-herdsman-converters/pull/1270
        exposes: [e.switch(), e.power(), e.current(), e.voltage().withAccess(ea.STATE),
            e.energy(), exposes.enum('power_outage_memory', ea.STATE_SET, ['on', 'off', 'restore'])
                .withDescription('Recover state after power outage')],
        onEvent: (type, data, device, options) => {
            const endpoint = device.getEndpoint(1);
            if (type === 'stop') {
                clearInterval(globalStore.getValue(device, 'interval'));
                globalStore.clearValue(device, 'interval');
            } else if (!globalStore.hasValue(device, 'interval')) {
                const seconds = options && options.measurement_poll_interval ? options.measurement_poll_interval : 60;
                if (seconds === -1) return;
                const interval = setInterval(async () => {
                    try {
                        await endpoint.read('haElectricalMeasurement', ['rmsVoltage', 'rmsCurrent', 'activePower']);
                    } catch (error) {/* Do nothing*/}
                }, seconds*1000);
                globalStore.putValue(device, 'interval', interval);
            }
        },
    }
]; 

After picking up this line from @iSenne and adding in the right place, I’ve got 100% of skills on.

await endpoint.read('seMetering', ['currentSummDelivered']);

1 Like

I guess this is Zigbee2MQTT code?
This thread is about ZHA…

Did you manage to solve this? I have the same issue with TS011F.

No, not at this time, but I would not recommend these plugs.

I was initially just computing the metering using the wattage…

sensor:
- platform: integration
  source: sensor.zigplug_power
  name: Zigplug computed Energy
  unit_prefix: k
  round: 2

It worked fine, but still not ideal.

So, apparently the plug needs us to poll the value and this can be easily done using the ZHA quirks.

Check this patch: Add support for Polled clusters and use it for ts011f plug Metering by 3v1n0 · Pull Request #1226 · zigpy/zha-device-handlers · GitHub

You can easily apply it to your installation by editing the files in: /usr/local/lib/python3.9/site-packages/zhaquirks (assuming hassio)

It’s now ok

is someone willing to post a full working external converter for this plug here. i cant seem to get it to work. i can turn them on and off but kwh keeps saying null.

i would like to know where to put this line ( await endpoint.read(‘seMetering’, [‘currentSummDelivered’]); ) in the code

Thanks!

Hi everyone!

So I was still facing the issue of my Lidl smart plug not exposing the energy field.

I “fixed” it (or hacked it) via Zigbee2Mqtt extensions. Here is my solution:


class ZoliZigbeeExtensionForLidlPlug {
    constructor(zigbee, mqtt, state, publishEntityState, eventBus, settings, logger) {
        logger.info('Loaded ZoliZigbeeExtensionForLidlPlug');
        this.zigbee = zigbee;
        this.logger = logger;
        this.eventBus = eventBus;
        this.eventBus.on('stateChange', this.onStateChange.bind(this), this.constructor.name);
    }

    async onStateChange(data) {
        const { entity, update } = data;
        
        if (entity._definition.model !== 'HG08673-FR') {
            return; // We don't care about other devices.
        }
        
        if ("energy" in update) {
            return; // Do not do anything otherwise we would end up in an infinite loop.
        }
        
        const device = this.zigbee.resolveEntity(entity.zh);
        const endpoint = device.zh.endpoints.find((e) => e.supportsInputCluster('seMetering'));
        
        try {
            await endpoint.read('seMetering', ['currentSummDelivered']);
        } catch (e) {
            this.logger.error("Error: Could not read seMetering: " + e);
        }
    }

    async stop() {
        this.eventBus.removeListeners(this.constructor.name);
    }
}

module.exports = ZoliZigbeeExtensionForLidlPlug;

Just add it to extensions and it should start reporting the energy as well. I hope it helps to someone.

Note: There was a bug in the previous version of the snippet. It wasn’t handling errors correctly which caused that zigbee2mqtt addon crashed frequently. The issue is fixed now.

2 Likes

Hey there,

would anyone have experience in running this with the Phoscon / deconz integration?

Thank you. It’s working great :+1:

1 Like