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

[Device Support Request] _TZE204_81yrt3lo TS0601 Zigbee power meter with clamp #2549

Open
Srjosep opened this issue Aug 28, 2023 · 84 comments
Open
Labels
Tuya Request/PR regarding a Tuya device

Comments

@Srjosep
Copy link

Srjosep commented Aug 28, 2023

Problem description

The device is discovered, but with no sensors. I have all connected fine, I can see total and instantaneous power in Tuya app. Where to start?

Solution description

Any

Screenshots/Video

Screenshots/Video

[Paste/upload your media here]

Device signature

Device signature
{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
  "endpoints": {
    "1": {
      "profile_id": "0x0104",
      "device_type": "0x0051",
      "input_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0xef00"
      ],
      "output_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": "0xa1e0",
      "device_type": "0x0061",
      "input_clusters": [],
      "output_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "_TZE204_81yrt3lo",
  "model": "TS0601",
  "class": "zigpy.device.Device"
}

Diagnostic information

Diagnostic information
{
  "home_assistant": {
    "installation_type": "Home Assistant Supervised",
    "version": "2023.5.4",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.11",
    "docker": true,
    "arch": "armv7l",
    "timezone": "Europe/Madrid",
    "os_name": "Linux",
    "os_version": "5.10.103-v7l+",
    "supervisor": "2023.08.1",
    "host_os": "Raspbian GNU/Linux 10 (buster)",
    "docker_version": "20.10.14",
    "chassis": "",
    "run_as_root": true
  },
  "custom_components": {
    "sonoff": {
      "version": "3.5.2",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    },
    "smartir": {
      "version": "1.17.7",
      "requirements": [
        "aiofiles>=0.6.0"
      ]
    },
    "hacs": {
      "version": "1.32.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "localtuya": {
      "version": "5.2.1",
      "requirements": []
    },
    "midea_ac_lan": {
      "version": "v0.3.18",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "after_dependencies": [
      "onboarding",
      "usb"
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga",
      "@puddly"
    ],
    "config_flow": true,
    "dependencies": [
      "file_upload"
    ],
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp"
    ],
    "requirements": [
      "bellows==0.35.5",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.99",
      "zigpy-deconz==0.21.0",
      "zigpy==0.55.0",
      "zigpy-xbee==0.18.0",
      "zigpy-zigate==0.11.0",
      "zigpy-znp==0.11.1"
    ],
    "usb": [
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*2652*",
        "known_devices": [
          "slae.sh cc2652rb stick"
        ]
      },
      {
        "vid": "1A86",
        "pid": "55D4",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus v2"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*zigstar*",
        "known_devices": [
          "ZigStar Coordinators"
        ]
      },
      {
        "vid": "1CF1",
        "pid": "0030",
        "description": "*conbee*",
        "known_devices": [
          "Conbee II"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8A2A",
        "description": "*zigbee*",
        "known_devices": [
          "Nortek HUSBZB-1"
        ]
      },
      {
        "vid": "0403",
        "pid": "6015",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate+"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8B34",
        "description": "*bv 2010/10*",
        "known_devices": [
          "Bitron Video AV2010/10"
        ]
      }
    ],
    "zeroconf": [
      {
        "type": "_esphomelib._tcp.local.",
        "name": "tube*"
      },
      {
        "type": "_zigate-zigbee-gateway._tcp.local.",
        "name": "*zigate*"
      },
      {
        "type": "_zigstar_gw._tcp.local.",
        "name": "*zigstar*"
      },
      {
        "type": "_slzb-06._tcp.local.",
        "name": "slzb-06*"
      }
    ],
    "is_built_in": true
  },
  "data": {
    "ieee": "**REDACTED**",
    "nwk": 11971,
    "manufacturer": "_TZE204_81yrt3lo",
    "model": "TS0601",
    "name": "_TZE204_81yrt3lo TS0601",
    "quirk_applied": false,
    "quirk_class": "zigpy.device.Device",
    "manufacturer_code": 4417,
    "power_source": "Mains",
    "lqi": 128,
    "rssi": -68,
    "last_seen": "2023-08-28T21:08:34",
    "available": true,
    "device_type": "Router",
    "signature": {
      "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
      "endpoints": {
        "1": {
          "profile_id": "0x0104",
          "device_type": "0x0051",
          "input_clusters": [
            "0x0000",
            "0x0004",
            "0x0005",
            "0xef00"
          ],
          "output_clusters": [
            "0x000a",
            "0x0019"
          ]
        },
        "242": {
          "profile_id": "0xa1e0",
          "device_type": "0x0061",
          "input_clusters": [],
          "output_clusters": [
            "0x0021"
          ]
        }
      },
      "manufacturer": "_TZE204_81yrt3lo",
      "model": "TS0601"
    },
    "active_coordinator": false,
    "entities": [],
    "neighbors": [],
    "routes": [],
    "endpoint_names": [
      {
        "name": "SMART_PLUG"
      },
      {
        "name": "unknown 97 device_type of 0xa1e0 profile id"
      }
    ],
    "user_given_name": null,
    "device_reg_id": "c7f139fc3dc0c3829df8cef20d87199b",
    "area_id": "594729d4701c4d73b9edf7c14a5818d8",
    "cluster_details": {
      "1": {
        "device_type": {
          "name": "SMART_PLUG",
          "id": 81
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0004": {
            "endpoint_attribute": "groups",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0005": {
            "endpoint_attribute": "scenes",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xef00": {
            "endpoint_attribute": null,
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {
              "0x0001": {
                "attribute_name": "app_version",
                "value": 74
              },
              "0x0004": {
                "attribute_name": "manufacturer",
                "value": "_TZE204_81yrt3lo"
              },
              "0x0005": {
                "attribute_name": "model",
                "value": "TS0601"
              }
            },
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x000a": {
            "endpoint_attribute": "time",
            "attributes": {},
            "unsupported_attributes": {}
          }
        }
      },
      "242": {
        "device_type": {
          "name": "unknown",
          "id": 97
        },
        "profile_id": 41440,
        "in_clusters": {},
        "out_clusters": {
          "0x0021": {
            "endpoint_attribute": "green_power",
            "attributes": {},
            "unsupported_attributes": {}
          }
        }
      }
    }
  }
}

Logs

Logs
[Paste the logs here]

Custom quirk

Custom quirk
[Paste your custom quirk here]

Additional information

No response

@TheJulianJES TheJulianJES added the Tuya Request/PR regarding a Tuya device label Aug 28, 2023
@Srjosep
Copy link
Author

Srjosep commented Aug 28, 2023

I saw there is quirk data for z2m, so I created a /config/zha_quirks/ folder, create the file Tuya_TZE204_81yrt3lo.js with this data, and added custom_quirks_path: /config/zha_quirks/ to configuration.yaml. But after reboot and repair, still no sensors. Must I delete pycache?Have no idea how to do it...

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 reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const utils = require('zigbee-herdsman-converters/lib/utils');
const e = exposes.presets;
const ea = exposes.access;
const {Buffer} = require('buffer');

const valueConverter = {
divideBy10: tuya.valueConverterBasic.divideBy(10),
divideBy100: tuya.valueConverterBasic.divideBy(100),
divideBy1000: tuya.valueConverterBasic.divideBy(1000),
};

const definition = {
fingerprint: [
{
modelID: 'TS0601',
manufacturerName: '_TZE204_81yrt3lo',
},
],
model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp',
vendor: 'TuYa',
description: 'Bidirectional Energy Meter with 80A Current Clamp',
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
onEvent: tuya.onEventSetTime,
configure: tuya.configureMagicPacket,
whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ],
// whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}],
exposes: [ //only report data
e.ac_frequency(),
exposes.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'),
exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'),
exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'),
exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'),
exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'),
exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'),
exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'),
exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'),
exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'),
exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'),
exposes.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'),
exposes.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'),
exposes.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'),
exposes.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'),
exposes.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'),
],

meta: {
tuyaDatapoints: [//only report data
[111, 'ac_frequency', tuya.valueConverter.divideBy100],
[101, 'total_power_A', tuya.valueConverter.divideBy10],
[105, 'total_power_B', tuya.valueConverter.divideBy10],
[115, 'total_power_AB', tuya.valueConverter.divideBy10],
[112, 'voltage', tuya.valueConverter.divideBy10],
[113, 'current_A', tuya.valueConverter.divideBy1000],
[114, 'current_B', tuya.valueConverter.divideBy1000],
[110, 'power_factor_A', tuya.valueConverter.divideBy100],
[121, 'power_factor_B', tuya.valueConverter.divideBy100],
[102, 'power_direction A', tuya.valueConverter.raw],
[104, 'power_direction B', tuya.valueConverter.raw],
[106, 'energy_forward_A', tuya.valueConverter.divideBy100],
[108, 'energy_forward_B', tuya.valueConverter.divideBy100],
[107, 'energy_reverse_A', tuya.valueConverter.divideBy100],
[109, 'energy_reverse_B', tuya.valueConverter.divideBy100],
[129, 'update_frequency' , tuya.valueConverter.raw],
],
},
};

module.exports = definition;

@Srjosep
Copy link
Author

Srjosep commented Aug 28, 2023

I think the quirk it's not applied, but I can't figure why... I followed all the steps... this is the log:

"manufacturer": "_TZE204_81yrt3lo",
"model": "TS0601",
"name": "_TZE204_81yrt3lo TS0601",
"quirk_applied": false,
"quirk_class": "zigpy.device.Device",

@MattWestb
Copy link
Contributor

In the opening post you have signature and diagnostic from the coordinator and not the device you have described. "device_type": "Coordinator".
Pleas updating them with information for the right device (device card).

@Srjosep
Copy link
Author

Srjosep commented Aug 28, 2023

Sorry, wrong device..... Fixed now. ( I Hope) :-)

@Srjosep
Copy link
Author

Srjosep commented Aug 29, 2023

Tried to add custom quirk to ZHA following https://github.com/home-assistant/home-assistant.io/pull/23884/files/e03462d75c7ad37c611ab3cf4d47210f7114bc94#diff-f6bd4d42fd2565238968333a466474a25384fb4eecddc0235902e5ff5e798c8d but still no sensors.
This means quirk isn't been applied, right? (Diagnose dump)
"manufacturer": "_TZE204_81yrt3lo",
"model": "TS0601",
"name": "_TZE204_81yrt3lo TS0601",
"quirk_applied": false,
"quirk_class": "zigpy.device.Device",

I am sure I followed all steps, creating the quirks folder and adding to yaml...
where could I start to look for the problem?

@MattWestb
Copy link
Contributor

"quirk_class": "zigpy.device.Device" = the device signature is ont matching your device, so need being fixed by adding it i the right device class in the quirk of if no working one making one new for your device.

@Srjosep
Copy link
Author

Srjosep commented Aug 29, 2023

I created a file called TS0601_Router.py inside "customs_zha_quirks" folder. And
zha: enable_quirks: true custom_quirks_path: /config/custom_zha_quirks/
to configuration.yaml
The data inside the file is
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 reporting = require('zigbee-herdsman-converters/lib/reporting'); const extend = require('zigbee-herdsman-converters/lib/extend'); const tuya = require('zigbee-herdsman-converters/lib/tuya'); const utils = require('zigbee-herdsman-converters/lib/utils'); const e = exposes.presets; const ea = exposes.access; const {Buffer} = require('buffer'); const valueConverter = { divideBy10: tuya.valueConverterBasic.divideBy(10), divideBy100: tuya.valueConverterBasic.divideBy(100), }; const definition = { fingerprint: [ { modelID: 'TS0601', manufacturerName: '_TZE204_81yrt3lo', }, ], model: 'TS0601_Bidirectional_Energy_Meter_with_80A_Current_Clamp', vendor: 'TuYa', description: 'Bidirectional Energy Meter with 80A Current Clamp', fromZigbee: [tuya.fz.datapoints], //, fz.ignore_tuya_set_time not working for No converter available for friendly_name with cluster manuSpecificTuya and type commandMcuSyncTime and data {payloadSize:XXX} toZigbee: [tuya.tz.datapoints], onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime' configure: tuya.configureMagicPacket, whiteLabel: [ tuya.whitelabel('Tuya', 'PJ-1203A', 'Bidirectional Energy Meter with 80A Current Clamp', ['_TZE204_81yrt3lo']), ], // whiteLabel: [{vendor: 'MatSeePlus', model: 'PJ-1203A'}], exposes: [ //only report data e.ac_frequency(), exposes.numeric('total_power_A', ea.STATE).withUnit('W').withDescription('Total power A'), exposes.numeric('total_power_B', ea.STATE).withUnit('W').withDescription('Total power B'), exposes.numeric('total_power_AB', ea.STATE).withUnit('W').withDescription('Total power A'), exposes.numeric('voltage', ea.STATE).withUnit('V').withDescription('Voltage'), exposes.numeric('current_A', ea.STATE).withUnit('A').withDescription('Current A'), exposes.numeric('current_B', ea.STATE).withUnit('A').withDescription('Current B'), exposes.numeric('power_factor_A', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor A'), exposes.numeric('power_factor_B', ea.STATE).withUnit('%').withDescription('Instantaneous measured power factor B'), exposes.numeric('power_direction A', ea.STATE).withDescription('Power direction A 0/1 for forward/reverse'), exposes.numeric('power_direction B', ea.STATE).withDescription('Power direction B 0/1 for forward/reverse'), exposes.numeric('energy_forward_A', ea.STATE).withUnit('kWh').withDescription('Total energy A forward'), exposes.numeric('energy_forward_B', ea.STATE).withUnit('kWh').withDescription('Total energy B forward'), exposes.numeric('energy_reverse_A', ea.STATE).withUnit('kWh').withDescription('Total energy A reverse'), exposes.numeric('energy_reverse_B', ea.STATE).withUnit('kWh').withDescription('Total energy B reverse'), exposes.numeric('update_frequency', ea.STATE).withUnit('sec').withDescription('Update frequency'), ], meta: { tuyaDatapoints: [//only report data [111, 'ac_frequency', tuya.valueConverter.divideBy100], [101, 'total_power_A', tuya.valueConverter.divideBy10], [105, 'total_power_B', tuya.valueConverter.divideBy10], [115, 'total_power_AB', tuya.valueConverter.divideBy10], [112, 'voltage', tuya.valueConverter.divideBy10], [113, 'current_A', tuya.valueConverter.divideBy100], [114, 'current_B', tuya.valueConverter.divideBy100], [110, 'power_factor_A', tuya.valueConverter.divideBy100], [121, 'power_factor_B', tuya.valueConverter.divideBy100], [102, 'power_direction A', tuya.valueConverter.raw], [104, 'power_direction B', tuya.valueConverter.raw], [106, 'energy_forward_A', tuya.valueConverter.divideBy100], [108, 'energy_forward_B', tuya.valueConverter.divideBy100], [107, 'energy_reverse_A', tuya.valueConverter.divideBy100], [109, 'energy_reverse_B', tuya.valueConverter.divideBy100], [129, 'update_frequency' , tuya.valueConverter.raw], ], }, }; module.exports = definition;

This is wrong? I have some devices apart of this one I'd like to fix to contribute. I'm on the learning process :-)
THANKS for your help

@MattWestb
Copy link
Contributor

You have posting Z2M code in the ZHA quirk and its not working.
You must doing one quirk from scratch if not can using one as temples and changing it so its working for your device.

@MattWestb
Copy link
Contributor

I think one good start i using this quirk and caning it so its working for your device if that is using the same DPs (tuya MCU commands).
https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts0601_din_power.py

@lhanneus
Copy link

I bought the same device and had the same problem.

I found this information : Koenkk/zigbee2mqtt#18419 (comment)

Hope it can help to fix the problem.

@Srjosep
Copy link
Author

Srjosep commented Sep 3, 2023

Quirk applied finally, and getting some data. Only Total power delivered and Power factor. Log:
"data": { "ieee": "**REDACTED**", "nwk": 56699, "manufacturer": "_TZE204_81yrt3lo", "model": "TS0601", "name": "_TZE204_81yrt3lo TS0601", "quirk_applied": true, "quirk_class": "TS0601_Router.TuyaPowerMeter_GPP", "manufacturer_code": 4417, "power_source": "Mains", "lqi": 76, "rssi": -81, "last_seen": "2023-09-03T12:31:15", "available": true, "device_type": "Router", "signature": { "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)", "endpoints": { "1": { "profile_id": "0x0104", "device_type": "0x0051", "input_clusters": [ "0x0000", "0x0004", "0x0005", "0x0702", "0x0b04", "0xef00" ], "output_clusters": [ "0x000a", "0x0019" ] }, "242": { "profile_id": "0xa1e0", "device_type": "0x0061", "input_clusters": [], "output_clusters": [ "0x0021" ] } }, "manufacturer": "_TZE204_81yrt3lo", "model": "TS0601" }, "active_coordinator": false, "entities": [ { "entity_id": "sensor.tze204_81yrt3lo_ts0601_power_factor", "name": "_TZE204_81yrt3lo TS0601" }, { "entity_id": "sensor.tze204_81yrt3lo_ts0601_summation_delivered", "name": "_TZE204_81yrt3lo TS0601" } ], "neighbors": [ { "device_type": "Coordinator", "rx_on_when_idle": "On", "relationship": "Parent", "extended_pan_id": "**REDACTED**", "ieee": "**REDACTED**", "nwk": "0x0000", "permit_joining": "Unknown", "depth": "0", "lqi": "33" }, { "device_type": "Router", "rx_on_when_idle": "On", "relationship": "Sibling", "extended_pan_id": "**REDACTED**", "ieee": "**REDACTED**", "nwk": "0x527C", "permit_joining": "Unknown", "depth": "0", "lqi": "112" } ], "routes": [], "endpoint_names": [ { "name": "SMART_PLUG" }, { "name": "PROXY_BASIC" } ], "user_given_name": null, "device_reg_id": "c7f139fc3dc0c3829df8cef20d87199b", "area_id": null, "cluster_details": { "1": { "device_type": { "name": "SMART_PLUG", "id": 81 }, "profile_id": 260, "in_clusters": { "0x0000": { "endpoint_attribute": "basic", "attributes": { "0x0001": { "attribute_name": "app_version", "value": 74 }, "0x0004": { "attribute_name": "manufacturer", "value": "_TZE204_81yrt3lo" }, "0x0005": { "attribute_name": "model", "value": "TS0601" } }, "unsupported_attributes": {} }, "0x0004": { "endpoint_attribute": "groups", "attributes": {}, "unsupported_attributes": {} }, "0x0005": { "endpoint_attribute": "scenes", "attributes": {}, "unsupported_attributes": {} }, "0xef00": { "endpoint_attribute": "tuya_manufacturer", "attributes": { "0x0201": { "attribute_name": "energy", "value": 6580 } }, "unsupported_attributes": {} }, "0x0b04": { "endpoint_attribute": "electrical_measurement", "attributes": { "0x0603": { "attribute_name": "ac_current_divisor", "value": 1000 }, "0x0602": { "attribute_name": "ac_current_multiplier", "value": 1 }, "0x0601": { "attribute_name": "ac_voltage_divisor", "value": 10 }, "0x0600": { "attribute_name": "ac_voltage_multiplier", "value": 1 } }, "unsupported_attributes": { "0x0400": { "attribute_name": "ac_frequency_multiplier" }, "0x0401": { "attribute_name": "ac_frequency_divisor" }, "0x0000": { "attribute_name": "measurement_type" }, "0x0403": { "attribute_name": "power_divisor" }, "0x0604": { "attribute_name": "ac_power_multiplier" }, "0x0605": { "attribute_name": "ac_power_divisor" }, "0x0402": { "attribute_name": "power_multiplier" }, "0x0508": { "attribute_name": "rms_current" }, "0x0505": { "attribute_name": "rms_voltage" }, "0x050a": { "attribute_name": "rms_current_max" }, "0x050b": { "attribute_name": "active_power" }, "0x050d": { "attribute_name": "active_power_max" }, "0x0507": { "attribute_name": "rms_voltage_max" }, "0x050f": { "attribute_name": "apparent_power" }, "0x0300": { "attribute_name": "ac_frequency" }, "0x0302": { "attribute_name": "ac_frequency_max" } } }, "0x0702": { "endpoint_attribute": "smartenergy_metering", "attributes": { "0x0000": { "attribute_name": "current_summ_delivered", "value": 6580 }, "0x0302": { "attribute_name": "divisor", "value": 100 }, "0x0300": { "attribute_name": "unit_of_measure", "value": 0 } }, "unsupported_attributes": { "0x0400": { "attribute_name": "instantaneous_demand" }, "0x0301": { "attribute_name": "multiplier" }, "0x0100": { "attribute_name": "current_tier1_summ_delivered" }, "0x0303": { "attribute_name": "summation_formatting" }, "0x0304": { "attribute_name": "demand_formatting" }, "0x0102": { "attribute_name": "current_tier2_summ_delivered" }, "0x0306": { "attribute_name": "metering_device_type" }, "0x0104": { "attribute_name": "current_tier3_summ_delivered" }, "0x0106": { "attribute_name": "current_tier4_summ_delivered" }, "0x0108": { "attribute_name": "current_tier5_summ_delivered" }, "0x010a": { "attribute_name": "current_tier6_summ_delivered" }, "0x0200": { "attribute_name": "status" } } } }, "out_clusters": { "0x000a": { "endpoint_attribute": "time", "attributes": {}, "unsupported_attributes": {} }, "0x0019": { "endpoint_attribute": "ota", "attributes": {}, "unsupported_attributes": {} } } }, "242": { "device_type": { "name": "PROXY_BASIC", "id": 97 }, "profile_id": 41440, "in_clusters": {}, "out_clusters": { "0x0021": { "endpoint_attribute": "green_power", "attributes": {}, "unsupported_attributes": {} } } } } } }

@Srjosep
Copy link
Author

Srjosep commented Sep 3, 2023

This sentences make the difference. With this, quirk isn't applied, and device have no sensor. Doesn't matter if the signature is right, quirk isn't applied.
PROFILE_ID: zgp.PROFILE_ID, DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
With this, quirk is applied, but only sensors for total power and power factor are show.
PROFILE_ID: 41440, DEVICE_TYPE: 97,

I have no idea what means the numbers or where find how it work,,,not much info about quirks development out there, anyway, I'll keep trying....

@BiduleMac
Copy link

BiduleMac commented Sep 3, 2023

Hello, I've just read your post, even following your parameters I don't get the power entities. Can you post your file ts0601_din_power.py for _TZE204_81yrt3lo please?

Do you confirm that once the file is placed in the custom_zha_quirks folder, I have to clear the ts0601_din_power.cpython-311.pyc cache and reboot HA? and rebuild or do I have to delete the device and reinstall it?

@Srjosep
Copy link
Author

Srjosep commented Sep 3, 2023

Yes, every time I do any change I delete the device, delete pycache file inside zha_quirks folder, and reboot HA.
This is what I get after pair again the device (only Power factor sensor):
image

And this after reboot again HA (one more sensor is discovered, "Summation delivered"). More HA reboots don't add more sensors.
image
And this is the file ts0601_din_power.py for _TZE204_81yrt3lo I use.
`"""Tuya Din Power Meter."""
from zigpy.profiles import zha
import zigpy.types as t
from zigpy.zcl.clusters.general import Basic, Groups, Ota, Scenes, Time, GreenPowerProxy
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.smartenergy import Metering

from zhaquirks import Bus, LocalDataCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.tuya import (
NoManufacturerCluster,
TuyaManufClusterAttributes,
TuyaSwitch,
)

import logging
_LOGGER = logging.getLogger(name)

TUYA_TOTAL_ENERGY_ATTR = 0x0201 #total energy /100 0x0211
TUYA_CURRENT_ATTR = 0x0011 #0x0212
TUYA_POWER_ATTR = 0x0006 #0x0213
TUYA_VOLTAGE_ATTR = 0x0004 #0x0214

class TuyaManufClusterDinPower(TuyaManufClusterAttributes):
"""Manufacturer Specific Cluster of the Tuya Power Meter device."""

attributes = {
    TUYA_TOTAL_ENERGY_ATTR: ("energy", t.uint16_t, True),
    TUYA_CURRENT_ATTR: ("current", t.int16s, True),      #t.int16s
    TUYA_POWER_ATTR: ("power", t.uint64_t, True),         #t.uint16_t
    TUYA_VOLTAGE_ATTR: ("voltage", t.uint16_t, True),
}

def _update_attribute(self, attrid, value):
    #super()._update_attribute(attrid, value)
    if attrid == TUYA_TOTAL_ENERGY_ATTR:
        self.endpoint.smartenergy_metering.energy_reported(value)
        super()._update_attribute(attrid, value)
    elif attrid == TUYA_CURRENT_ATTR:
        _LOGGER.warning("TUYA_CURRENT_ATTR (0x%04x) value: %d (0x%x)" % (attrid, value, value))
    elif attrid == TUYA_POWER_ATTR:
        self.endpoint.electrical_measurement.voltage_reported((value >> 48) & 0xffff)
        self.endpoint.electrical_measurement.current_reported((value >> 24) & 0xffffff)
        self.endpoint.electrical_measurement.power_reported(value & 0xffffff)
        super()._update_attribute(TUYA_VOLTAGE_ATTR, (value >> 48) & 0xffff)
        super()._update_attribute(TUYA_CURRENT_ATTR, (value >> 24) & 0xffffff)
        super()._update_attribute(TUYA_POWER_ATTR, value & 0xffffff)
    elif attrid == TUYA_VOLTAGE_ATTR:
        _LOGGER.warning("TUYA_VOLTAGE_ATTR (0x%04x) value: %d (0x%x)" % (attrid, value, value))
    else:
        super()._update_attribute(attrid, value)
        _LOGGER.warning("attrid: 0x%04x value: %d (0x%x)" % (attrid, value, value))

class TuyaPowerMeasurement(LocalDataCluster, ElectricalMeasurement):
"""Custom class for power, voltage and current measurement."""

cluster_id = ElectricalMeasurement.cluster_id

POWER_ID = 0x050b             #0x050B
VOLTAGE_ID = 0x0505
CURRENT_ID = 0x0508

AC_VOLTAGE_MULTIPLIER = 0x0600
AC_VOLTAGE_DIVISOR = 0x0601
AC_CURRENT_MULTIPLIER = 0x0602
AC_CURRENT_DIVISOR = 0x0603

_CONSTANT_ATTRIBUTES = {AC_CURRENT_MULTIPLIER: 1, AC_CURRENT_DIVISOR: 1000, AC_VOLTAGE_MULTIPLIER: 1, AC_VOLTAGE_DIVISOR: 10}

def voltage_reported(self, value):
    """Voltage reported."""
    self._update_attribute(self.VOLTAGE_ID, value)

def power_reported(self, value):
    """Power reported."""
    self._update_attribute(self.POWER_ID, value)

def current_reported(self, value):
    """Ampers reported."""
    self._update_attribute(self.CURRENT_ID, value)

class TuyaElectricalMeasurement(LocalDataCluster, Metering):
"""Custom class for total energy measurement."""

cluster_id = Metering.cluster_id
CURRENT_SUMM_DELIVERED_ID = 0x0000
UNIT_OF_MEASURE_ID = 0x0300
MULTIPLIER_ID = 0x0301
DIVISOR_ID = 0x0302
POWER_WATT_ENUM = 0x0000

"""Setting unit of measurement."""
_CONSTANT_ATTRIBUTES = {UNIT_OF_MEASURE_ID: POWER_WATT_ENUM, DIVISOR_ID: 100}

def energy_reported(self, value):
    """Summation Energy reported."""
    self._update_attribute(self.CURRENT_SUMM_DELIVERED_ID, value)

class TuyaPowerMeter(TuyaSwitch):
"""Tuya power meter device."""

signature = {
    # "node_descriptor": "<NodeDescriptor byte1=1 byte2=64 mac_capability_flags=142 manufacturer_code=4098
    #                       maximum_buffer_size=82 maximum_incoming_transfer_size=82 server_mask=11264
    #                       maximum_outgoing_transfer_size=82 descriptor_capability_field=0>",
    # device_version=1
    # input_clusters=[0x0000, 0x0004, 0x0005, 0xef00]
    # output_clusters=[0x000a, 0x0019]
    MODELS_INFO: [
        ("_TZE200_byzdayie", "TS0601"),
        ("_TZE200_ewxhg6o9", "TS0601"),
        ("_TZE204_81yrt3lo", "TS0601"),
    ],
    ENDPOINTS: {
        # <SimpleDescriptor endpoint=1 profile=260 device_type=51
        # device_version=1
        # input_clusters=[0, 4, 5, 61184]
        # output_clusters=[10, 25]>
        1: {
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
            INPUT_CLUSTERS: [
                Basic.cluster_id,
                Groups.cluster_id,
                Scenes.cluster_id,
                TuyaManufClusterAttributes.cluster_id,
            ],
            OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
        }
    },
}

replacement = {
    ENDPOINTS: {
        1: {
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
            INPUT_CLUSTERS: [
                Basic.cluster_id,
                Groups.cluster_id,
                Scenes.cluster_id,
                TuyaManufClusterDinPower,
                TuyaPowerMeasurement,
                TuyaElectricalMeasurement,
            ],
            OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
        }
    }
}

class TuyaPowerMeter_GPP(TuyaSwitch):
"""Tuya power meter device."""

signature = {
    # "node_descriptor": "<NodeDescriptor byte1=1 byte2=64 mac_capability_flags=142 manufacturer_code=4417
    #                       maximum_buffer_size=66 maximum_incoming_transfer_size=66 server_mask=10752
    #                       maximum_outgoing_transfer_size=66 descriptor_capability_field=0>",
    # device_version=1
    # input_clusters=[0x0000, 0x0004, 0x0005, 0xef00]
    # output_clusters=[0x000a, 0x0019]
    MODELS_INFO: [
        ("_TZE200_lsanae15", "TS0601"),
        ("_TZE204_81yrt3lo", "TS0601"),
    ],
    ENDPOINTS: {
        # <SimpleDescriptor endpoint=1 profile=260 device_type=51
        # device_version=1
        # input_clusters=[0, 4, 5, 61184]
        # output_clusters=[10, 25]>
        1: {
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
            INPUT_CLUSTERS: [
                Basic.cluster_id,
                Groups.cluster_id,
                Scenes.cluster_id,
                TuyaManufClusterAttributes.cluster_id,
            ],
            OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
        },
        242: {
            # <SimpleDescriptor endpoint=242 profile=41440 device_type=61
            # input_clusters=[]
            # output_clusters=[21]
            PROFILE_ID: 41440,
            DEVICE_TYPE: 97,
            INPUT_CLUSTERS: [],
            OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
        },
    },
}

replacement = {
    ENDPOINTS: {
        1: {
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
            INPUT_CLUSTERS: [
                Basic.cluster_id,
                Groups.cluster_id,
                Scenes.cluster_id,
                TuyaManufClusterDinPower,
                TuyaPowerMeasurement,
                TuyaElectricalMeasurement,
            ],
            OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
        },
        242: {
            # <SimpleDescriptor endpoint=242 profile=41440 device_type=61
            # input_clusters=[]
            # output_clusters=[21]
            PROFILE_ID: 41440,
            DEVICE_TYPE: 97,
            INPUT_CLUSTERS: [],
            OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
        },
    }`

@BiduleMac
Copy link

BiduleMac commented Sep 3, 2023

Do you think you could send me the whole file at once? I've gone step by step, but it doesn't work.
;-)

Are file indentations mandatory (as in YAML)?

After trying several times, still nothing.

Once the file has been created according to your model, I don't get the "Power Factor" entity on the first startup, and nothing either on the second startup.

@Srjosep
Copy link
Author

Srjosep commented Sep 4, 2023

The folder must be pointed in configuration.raml, something like

zha:
enable_quirks: true
custom_quirks_path: /config/zha_quirks/

Pointing to your quirks folder.
Can you see the quirk applied in the device info?
image
I read the clamp must be connected, in right position, and there must be power in the wire to get the sensors... I didn't tried with the clamp off, so, I am not sure if this is needed. I tried with Tuya app before, and only after getting all data working fine, deleted the device from tuya app and starting with ZHA.
Here is the file. I called it ts0601_powermeter to avoid duplicated names.
ts0601_powermeter.zip

@BiduleMac
Copy link

Yes !!
thanks for the file, it worked immediately.
the first "Power factor" sensor actually appeared on the first boot, and the second "Summation delivered" after the second reboot.

for your information, the second "Summation delivered" sensor appeared with the clamp closed (currently at 0.0kWh), my blank assembly.

I'm going back to my temporary set-up to measure a significant current.
Many thanks for this great step forward .

But I'm going to ask you again, and maybe you won't be able to answer me, the model I have has 2 sensors, and I can only see one :-(

Do you have any idea how to activate the second sensor to help me in my search? I didn't go through TUYA, I don't have an independent gateway, and I didn't manage to associate it in Zigbee on the application.

thanks again, I'm desperate after 150 restarts.

@Srjosep
Copy link
Author

Srjosep commented Sep 4, 2023

Mine have two sensors plug too, for use with solar or wind generators. I use only one because I have no generators i+right now. This device have much more sensors, like voltage, actual consumption, etc... I am trying to get all working, but there is info (or I can't find it) about quirks creation, so I am blindfolding, just trying things....you can see all the sensors available and the entrypoints here Koenkk/zigbee2mqtt#18419 (comment) but I don't know how translate from z2mqtt to ZHA. Any progress I will post here, if any... any suggestion, progress, you make, please let me know...

@BiduleMac
Copy link

OK I'm looking
yes, of course I'll publish here if I make any progress

@maccmaic
Copy link

maccmaic commented Sep 5, 2023

ts0601_din_power_MatSee.zip
Hi, i made this file using TuyaPowerMeter_GPP. Not work 100% but is near.
image

@BiduleMac
Copy link

BiduleMac commented Sep 5, 2023

👍 Great
It works for me, but I only have one sensor on both, a track to activate the second?

@Srjosep
Copy link
Author

Srjosep commented Sep 5, 2023

You make my day, it works like charm... just have a doubt about the active power... a current of 2.4Ah at 235volts = 566 W... but indicate 4122 w... It seems there is something wrong...
image

@Srjosep
Copy link
Author

Srjosep commented Sep 5, 2023

This is the screen capture of Tuya app. It seems to need some calibration too, (is possible to modify calibration factor in the app). Last number in active power must be decimal... and seems in this quirk "summation delivered" refers to reverse energy, not forward energy as TuyaPowerMeter_GPP do..... but you did a GREAT job. Thanks. BiduleMac could confirm this, I have only one clamp for forward energy because I have no solar generator yet.
image

@fernac03
Copy link

fernac03 commented Sep 6, 2023

Great ,
is work for me.
I have two sensors, how do I show the second one?
Is the reverse for the network already working?

@BiduleMac
Copy link

Concerning the two sensors, I noticed with the latest version of @maccmaic that both sensors are present (in Manage Zigbee device) and the values updated, but I don't understand how to make them appear as entities. In fact, I'm trying to understand the structure of the file, but the display part escapes me ;-(.

@fernac03
Copy link

fernac03 commented Sep 7, 2023

from what I saw in the code only the attributes energy_deliver_reported and energy_deliver_reported
are being reported channel B is commented

@maccmaic
Copy link

maccmaic commented Sep 7, 2023

I have tried to change delivered/recived but the integration not working.
Sorry, i dont know the architecture and is the first time programming in python.
image

If someone know why?

For channel B, I tried to report the CURRENT_TIER1_DELIVERED_ID attribute of the TuyaElectricalMeasurement class but it didn't work either.

The bad thing is that when I modify things that should not affect the rest, it stops showing all the entities.

@BiduleMac
Copy link

BiduleMac commented Sep 7, 2023

in my searches on Github, I don't see any TS601 displaying 2 sensors ....

what's surprising is that the data from the 2 sensors do indeed show up in ZHA, you can see them vary in the "manage Zigbee device" menu, then "MatSeeManufClusterDinPower" and current & currentB with the values 0x000 and 0X001, and this is also true for power and current.

Capture d’écran 2023-09-07 à 17 51 01
Capture d’écran 2023-09-07 à 17 51 18

I can't figure out how to define the transition to entities.

jeverley added a commit to jeverley/zha-device-handlers that referenced this issue Feb 1, 2024
Aims to address device support requests:

2 bidirectional clamps:
zigpy#2549 (_TZE204_81yrt3lo)
zigpy#2650 (_TZE200_rks0sgb7)

1 bidirectional clamp:
zigpy#2420 (_TZE204_ac0fhfiq)

1 clamp:
zigpy#1973 (_TZE204_cjbofhxw)

@jmuf I've just spotted that in parallel you've also been working on zigpy#2870 for 
_TZE200_rks0sgb7, shall we pool ideas?
@jeverley
Copy link
Contributor

jeverley commented Feb 1, 2024

@jeverley RE: home-assistant/core#107576 It's not an issue in your PR, but due to how ZHA currently handles initializing attributes and creating entities, there are some "useless entities" created until ZHA has fully initialized once and ZHA restarted. Then, they stay as "ghost entities" that can be deleted.

We're currently trying to think of a proper solution for this, but could you provide the diagnostics/device signature(s) for the device(s) you need those sensors to be available on (just in case)? If it's multiple Tuya devices that require a quirk anyway, we could assign quirk_id in quirks and match that in ZHA, so the current_summ_received only gets created for matching entities for now. (Seems like it's supported by very few devices anyway) Just so we can "work around" the issue of creating useless entities for all power-measurement devices before the 2024.2.0 release.

Hi @TheJulianJES here's my current draft PR #2961, it aims to add functionality for the different Tuya clamp Energy Meter devices I've tracked down.

We could potentially include a quirk_id in there, but it also includes the full list of device fingerprints that I'm mapping the value for.

@marcogeni
Copy link

Thank you all for the work, I've just integrated this Power Meter with 2 clamps through the custom quirk.

Best regards, Marco

@marceloajunqueira
Copy link

I have the exactly same device.
When I add the device to ZHA, only the Power Factor sensors are added.
I know that the Quirck is working because I can see the "Active_Power" on the 3 endpoints in the Device Info Popup.
Do I need to force anything to add the other sensors?

Apologies for the delay in responding, I've been working on the PRs to expose the summation received sensors in Home Assiustant core - that functionality is now merged home-assistant/core#107576, so I can focus my efforts on working out remaining issues with the device quirk.

Did the issue of only seeing Power factor sensors resolve after a restart of ZHA?

I did a HA restart after the installation, but In my case, all Readings appeared suddenly after 5 days. I don't know why, but it's working like a charm now.

@eyalsac
Copy link

eyalsac commented Mar 2, 2024

Thank you all for the work, I've just integrated this Power Meter with 2 clamps through the custom quirk.

Best regards, Marco

Dear Marco
which quirk exsactly you used?

@marcogeni
Copy link

Hello Eyalsac, I downloaded the ts0601_energy_meter.py file from the repository reported in the previous posts.
This should be the link: https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter/zhaquirks/tuya/ts0601_energy_meter.py

@eyalsac
Copy link

eyalsac commented Mar 3, 2024

Thank you very much.
It work for me now!

@atspro
Copy link

atspro commented Apr 11, 2024

Hello
I also pulled this code for _TZE204_81yrt3lo. Everything works properly. Would it be possible for the frequency not to be rounded to one place, but to two places after the decimal point? Then everything would be perfect for me.
In ac_frequency (id: 0x0300) it shows 5001 but rounds to 50.00
Thanks in advance
newbie in HA
Ats

@jeverley
Copy link
Contributor

Hello I also pulled this code for _TZE204_81yrt3lo. Everything works properly. Would it be possible for the frequency not to be rounded to one place, but to two places after the decimal point? Then everything would be perfect for me. In ac_frequency (id: 0x0300) it shows 5001 but rounds to 50.00 Thanks in advance newbie in HA Ats

Hi @atspro , are you using the version below?

https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter_devices/zhaquirks/tuya/ts0601_energy_meter.py

The version posted by @eyalsac is on an old branch, using the above I have the correct decimal places on my end (it's also the version I'm working actively on to support multiple devices).

@atspro
Copy link

atspro commented Apr 18, 2024

Hello I also pulled this code for _TZE204_81yrt3lo. Everything works properly. Would it be possible for the frequency not to be rounded to one place, but to two places after the decimal point? Then everything would be perfect for me. In ac_frequency (id: 0x0300) it shows 5001 but rounds to 50.00 Thanks in advance newbie in HA Ats

Hi @atspro , are you using the version below?

https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter_devices/zhaquirks/tuya/ts0601_energy_meter.py

The version posted by @eyalsac is on an old branch, using the above I have the correct decimal places on my end (it's also the version I'm working actively on to support multiple devices).

Good work, many thanks for the new code. Now I have all the fields with correct data.
My question is whether it would be possible to remove the frequency rounding in the UI.
Currently, one place after the decimal point is rounded (50,0Hz)
If 4999 comes from the Unit, so that the UI also shows 49.99Hz

@guirem
Copy link
Contributor

guirem commented Apr 18, 2024

Hi @jeverley ,
Do you know how to reset total sum delivered and received for clamps ?
I tried overwriting values in TuyaMetering cluster endpoint 1 below (see screenshot).
It seemed to work for few seconds as I could read the 0 value I tried to write and sensor showed 0 but then it came back to original value.
I also tried to run factory reset command in Basic endpoint but doesn't seem to do anything.

image

@tikes
Copy link

tikes commented Apr 26, 2024

Hi all,

I've added this quirk, but I don't have any values. The only ones that keep changing are the Ac Frequency and the Voltage as you can see in image.
I'm using this quirk:
https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter_devices/zhaquirks/tuya/ts0601_energy_meter.py

Any thouths why this happen?
Thanks
meter

@jeverley
Copy link
Contributor

Hi all,

I've added this quirk, but I don't have any values. The only ones that keep changing are the Ac Frequency and the Voltage as you can see in image.
I'm using this quirk:
https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter_devices/zhaquirks/tuya/ts0601_energy_meter.py

Any thouths why this happen?
Thanks
meter

Hi @tikes , did any start populating following a second reload of the ZHA integration?
Also what version of home assistant core are you running?

@tikes
Copy link

tikes commented Apr 28, 2024

Hi @jeverley, no, already restart home assistant several times. Reload Zha. Delete and add again the device. Already follow this steps #2961 (comment).

I'm running Core version: 2024.4.4

Thanks

@jovanyeo
Copy link

jovanyeo commented May 3, 2024

Hi Guru, out there.
Mine also not populating.

image

@flybrys
Copy link

flybrys commented Jun 5, 2024

Hi @jeverley , thanks so much for this quirk. This was the last device I needed to get working so now my home is complete.

I have some questions for you if you have time:

  1. Z2M has a configuration option for update frequency. Same as the Tuya app. Can this be added also?
  2. I have 5x summation delivered sensors. Am I correct to assume 2 are for clamps 1 and 2 consumed, 2 are for clamps 1 and 2 returned, and the 5th is for a net figure of all this?
  3. What is apparent power actually measuring? My basic understanding is VA = W so why is my wattage use only 385ish but apparent power 709VA
  4. What's the difference between Instantaneous Demand and Power?
  5. Are there plans or a PR to merge this quirk into the ZHA core?

Sorry if I've missed any of these in the comments above. Many thanks for your work on this.

@JamesCuneo
Copy link

Hi Guru, out there. Mine also not populating.

image

You need to enable the entities.

@Dominic-070
Copy link

@type-rke
Copy link

Hello I also pulled this code for _TZE204_81yrt3lo. Everything works properly. Would it be possible for the frequency not to be rounded to one place, but to two places after the decimal point? Then everything would be perfect for me. In ac_frequency (id: 0x0300) it shows 5001 but rounds to 50.00 Thanks in advance newbie in HA Ats

Hi @atspro , are you using the version below?

https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter_devices/zhaquirks/tuya/ts0601_energy_meter.py

The version posted by @eyalsac is on an old branch, using the above I have the correct decimal places on my end (it's also the version I'm working actively on to support multiple devices).

Hi, the file is not availible anymore?

@remizik
Copy link

remizik commented Aug 28, 2024

Hello I also pulled this code for _TZE204_81yrt3lo. Everything works properly. Would it be possible for the frequency not to be rounded to one place, but to two places after the decimal point? Then everything would be perfect for me. In ac_frequency (id: 0x0300) it shows 5001 but rounds to 50.00 Thanks in advance newbie in HA Ats

Hi @atspro , are you using the version below?
https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter_devices/zhaquirks/tuya/ts0601_energy_meter.py
The version posted by @eyalsac is on an old branch, using the above I have the correct decimal places on my end (it's also the version I'm working actively on to support multiple devices).

Hi, the file is not availible anymore?

The link works for me.

@remizik
Copy link

remizik commented Aug 28, 2024

I'm a bit confused with the triple sensors :

image

Sometimes the 1st of the 3 is at 0 value or Unknown, sometimes it's the 3rd one.

@remizik
Copy link

remizik commented Aug 28, 2024

3. What is apparent power actually measuring? My basic understanding is VA = W so why is my wattage use only 385ish but apparent power 709VA

Same question here

@ml0renz0
Copy link

3. What is apparent power actually measuring? My basic understanding is VA = W so why is my wattage use only 385ish but apparent power 709VA

Same question here

This helped me understand it

@olivierberthomme
Copy link

Hello I also pulled this code for _TZE204_81yrt3lo. Everything works properly. Would it be possible for the frequency not to be rounded to one place, but to two places after the decimal point? Then everything would be perfect for me. In ac_frequency (id: 0x0300) it shows 5001 but rounds to 50.00 Thanks in advance newbie in HA Ats

Hi @atspro , are you using the version below?

https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter_devices/zhaquirks/tuya/ts0601_energy_meter.py

The version posted by @eyalsac is on an old branch, using the above I have the correct decimal places on my end (it's also the version I'm working actively on to support multiple devices).

I also confirm this one works for me (HAOS Home Assistant OS 13.1 - HA core-2024.9.0). How can we vote somewhere to push this quirk to standard?
Thanks @jeverley

@sloaiza86
Copy link

I'm a bit confused with the triple sensors :

image

Sometimes the 1st of the 3 is at 0 value or Unknown, sometimes it's the 3rd one.

Were you able to understand this?? I have the same doubt.

@remizik
Copy link

remizik commented Sep 19, 2024

I'm a bit confused with the triple sensors :
image
Sometimes the 1st of the 3 is at 0 value or Unknown, sometimes it's the 3rd one.

Were you able to understand this?? I have the same doubt.

Yes, the two first ones are the individual clamps.
Looks like the 3rd is the combination of the two, even though the values are a bit off..

@ketukil
Copy link

ketukil commented Sep 29, 2024

Hello I also pulled this code for _TZE204_81yrt3lo. Everything works properly. Would it be possible for the frequency not to be rounded to one place, but to two places after the decimal point? Then everything would be perfect for me. In ac_frequency (id: 0x0300) it shows 5001 but rounds to 50.00 Thanks in advance newbie in HA Ats

Hi @atspro , are you using the version below?
https://github.com/jeverley/zha-device-handlers/blob/ts0601_energy_meter_devices/zhaquirks/tuya/ts0601_energy_meter.py
The version posted by @eyalsac is on an old branch, using the above I have the correct decimal places on my end (it's also the version I'm working actively on to support multiple devices).

I also confirm this one works for me (HAOS Home Assistant OS 13.1 - HA core-2024.9.0). How can we vote somewhere to push this quirk to standard? Thanks @jeverley

I can finally confirm that this thing works for 2 clamp power meter _TZE204_81yrt3lo. A bit of testing is ahead to see if measurements are fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

No branches or pull requests