Hello
I also have these power plug bought on Ali, no power meter measurement. Zigbee2mqtt find all these entry, but any value are « null ».
Support for TS011F has been improved lately in Zigpy (lib used by ZHA) but we need to wait for a new release
Power measurement works on ZHA, I’ve tried. But not on zigbee2mqtt.
Do you know when it will be plublished on the next released of zigbee2mqtt, because this my zigbee integration (not ZHA).
It seems already supported:
Unfortunately, it doesn’t work for me on zigbee2mqtt. My others plugs as aqara work.
Look under the tab “Expose”. It can take a while before all attributes have values
FYI, remaining issues now lie in to get correct multiplier/divider factors into zha quirk all devices, see:
https://github.com/zigpy/zha-device-handlers/issues?q=
https://github.com/zigpy/zha-device-handlers/pulls?q=
Some information here in ZHA docs why ZHA device handlers are needed to fix some devices quirks:
https://www.home-assistant.io/integrations/zha/#zha-exception-and-deviation-handling
Oke, just checked again and it seems like I lied… Sorry. Ths plug I thougt was a ’ TS011F_plug’ was actually a ‘TS0121_plug’. I checked my other plug, and turns out zigbee2mqtt doesn’t have the values
{
"current": null,
"energy": null,
"linkquality": 23,
"power": null,
"power_outage_memory": "on",
"state": "ON",
"voltage": null
}
Okay, I’ve been testing with the TS011F plug (_TZ3000_dpo1ysak) to get it to work. I tried to add it as a Tuya device via an external converter based on the documentation and the code already in zigbee-herdsman-converters. This is what I came up with:
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const e = exposes.presets;
const ea = exposes.access;
const definition = {
fingerprint: [
{modelID: 'TS011F', manufacturerName: '_TZ3000_dpo1ysak'},
{modelID: 'TS011F', manufacturerName: '_TZ3000_cphmq0q7', applicationVersion: 69}
],
model: 'TS011F_plug_4',
description: 'Smart plug (with custom power monitoring by polling)',
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);
endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {
acCurrentDivisor: 1000,
acCurrentMultiplier: 1
});
endpoint.saveClusterAttributeKeyValue('seMetering', {divisor: 100, multiplier: 1});
device.save();
},
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 = 60;
const interval = setInterval(async () => {
try {
await endpoint.read('haElectricalMeasurement', ['rmsVoltage', 'rmsCurrent', 'activePower']);
await endpoint.read('seMetering', ['currentSummDelivered']);
} catch (error) {
/* Do nothing*/
}
}, seconds * 1000);
globalStore.putValue(device, 'interval', interval);
}
},
};
module.exports = definition;
After some debugging and trying, I could not get any other attribute then ‘state’ and ’ linkquality’. Even when I add the same device again, it still doesn’t get anything except those two.
MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"message":"interview_successful","meta":{"description":"Smart plug (with custom power monitoring by polling)","friendly_name":"0x540f57fffe19e97b","model":"TS011F_plug_4","supported":true,"vendor":"TuYa"},"type":"pairing"}'
Configuring '0x540f57fffe19e97b'
Successfully configured '0x540f57fffe19e97b'
MQTT publish: topic 'zigbee2mqtt/0x540f57fffe19e97b', payload '{"current":null,"energy":null,"linkquality":57,"power":null,"power_outage_memory":null,"state":"OFF","voltage":null}'
When will the release be available? I’d be happy to beta test, as I also have a TS011F and voltage shows 0.2V instead 230V.
I don’t know. Soon I hope because I have the same issue
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']);
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)