dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.88k stars 483 forks source link

PJ-1203A - Tuya Zigbee power meter with 2 clamps #7324

Closed aldoushx closed 7 months ago

aldoushx commented 8 months ago

Is there already an existing issue for this?

Product name

power meter

Electricity Energy Monitor

Manufacturer

_TZE204_81yrt3lo

Model identifier

TS0601

Device type to add

Sensor

Node info

cluster list

node info 1 node info 2

Endpoints and clusters

Scenes Groups

Basic

cluster info cluster info2

Further relevant clusters

Power Configuration

On/Off

Level Control

Color Control

Thermostat

Simple Metering

Electrical Measurement

Any other cluster of relevance/interest

Smanar commented 8 months ago

Hello, you miss the node picture with the cluster list. Can start with this DDF

{
  "schema": "devcap1.schema.json",
  "manufacturername": ["_TZE204_81yrt3lo", "_TZE200_rks0sgb7"],
  "modelid": ["TS0601", "TS0601"],
  "product": "PJ-1203A - Zigbee power meter with 2 clamps",
  "sleeper": true,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_CONSUMPTION_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0702"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",
          "parse": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001"}
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/offset",
          "default": 0
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/consumption",
          "parse": {"fn": "tuya", "dpid": 106, "eval": "Item.val = Attr.val / 100;" },
          "read": {"fn": "none"},
          "default": 0
        },
        {
          "name": "state/lastupdated"
        }
      ]
    },
    {
      "type": "$TYPE_POWER_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0b04"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",
          "parse": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "none"}
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/offset",
          "default": 0
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/current",
          "parse": {"fn": "tuya", "dpid": 113, "eval": "Item.val = Attr.val / 1000;" },
          "read": {"fn": "none"},
          "default": 0
        },
        {
          "name": "state/voltage",
          "parse": {"fn": "tuya", "dpid":112, "eval": "Item.val = Attr.val / 10;" },
          "read": {"fn": "none"},
          "default": 0
        },
        {
          "name": "state/power",
          "parse": {"fn": "tuya", "dpid": 101, "eval": "Item.val = Attr.val / 10;" },
          "read": {"fn": "none"},
          "default": 0
        }
      ]
    },
    {
      "type": "$TYPE_CONSUMPTION_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x02",
        "0x0702"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",
          "parse": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001"}
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/offset",
          "default": 0
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/consumption",
          "parse": {"fn": "tuya", "dpid": 108, "eval": "Item.val = Attr.val / 100;" },
          "read": {"fn": "none"},
          "default": 0
        },
        {
          "name": "state/lastupdated"
        }
      ]
    },
    {
      "type": "$TYPE_POWER_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x02",
        "0x0b04"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",
          "parse": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "none"}
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/offset",
          "default": 0
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/current",
          "parse": {"fn": "tuya", "dpid": 114, "eval": "Item.val = Attr.val / 1000;" },
          "read": {"fn": "none"},
          "default": 0
        },
        {
          "name": "state/voltage",
          "parse": {"fn": "tuya", "dpid":112, "eval": "Item.val = Attr.val / 10;" },
          "read": {"fn": "none"},
          "default": 0
        },
        {
          "name": "state/power",
          "parse": {"fn": "tuya", "dpid": 105, "eval": "Item.val = Attr.val / 10;" },
          "read": {"fn": "none"},
          "default": 0
        }
      ]
    }
  ]
}
aldoushx commented 8 months ago

Thank you for your answer, I updated the 1st message with the node picture.

For an unknown reason, I cannot edit/save the ddf in the editor with the ddf provided above : I open the json in the ddf editor window of the device, the data is well displayed in the ddf editor, but when i save it, close the window then go back in the editor, the ddf is back to the initial data... I tried after a hot reload, and after deleting/reinclude the node, but i get the same result every time, the ddf is not saved.

Any idea what it could be ? That is the first time I see this behaviour with a ddf...

Smanar commented 8 months ago

You can't use the editor. What is your OS ? You need to create a text file called what_you_want.json in a "devices" folder, but it will depend of your OS.

aldoushx commented 8 months ago

I know the procedure, but the ddf.json file does not stay loaded in the editor after I opened it and saved (unlike the other ddf files I used for other devices). My setup : graphic deconz interface on an ubuntu VM, no problem with other ddf and devices.

Smanar commented 8 months ago

Don't use the deconz editor, I don't think it's able to manage tuya device, better to use a text editor. Close deconz, put the file in one of the 2 "devices" folder, and reload deconz.

aldoushx commented 8 months ago

I don't know why but saving and loading the ddf file in another directory worked... Anyway, the ddf provided above is working well for the power measure by the 2 clamps, but not for the energy consumption.

Smanar commented 8 months ago

You have zero values or bad one ? Perhaps the /100 is too much. You haven't the GUI to check logs ? with deconz/help/debug veiw with flag "DDF"

aldoushx commented 8 months ago

The consumption values were ridiculously low in Home Assistant, so I assumed they were not returned. I then changed the /100 by *10 in the ddf and now the values are the right ones (in Wh in deconz debug). I can also see the current and voltage values in the deconz debug window, but these values are not returned as sensors in HA.

Smanar commented 8 months ago

Can you take a look direclty in the api ? Using phoscon/help/API Information/sensors.

aldoushx commented 8 months ago

It the API, the voltage and current values are displayed (curently at 0 for the current, as there is no power consumption)

{
    "config": {
        "offset": 0,
        "on": true,
        "reachable": true
    },
    "etag": "11d7731910045ed5a11b959d8704db9b",
    "lastannounced": null,
    "lastseen": "2023-10-31T21:06Z",
    "manufacturername": "_TZE204_81yrt3lo",
    "modelid": "TS0601",
    "name": "Power 113",
    "state": {
        "current": 0,
        "lastupdated": "2023-10-31T21:06:59.519",
        "power": 0,
        "voltage": 236
    },
    "type": "ZHAPower",
    "uniqueid": "a4:c1:38:1e:ff:ed:10:fd-01-0b04"
}
Smanar commented 8 months ago

Ok, so you know the method to "refresh" a device in HA ? for exemple delete it in HA and not deconz, then relaod it ?

If I m right HA create the entry the first time it see the device, so if the state/voltage was missing at this moment, it will stay missing, even it will apear later.

Because all seem fine for me, no reason to don't have the voltage.

github-actions[bot] commented 7 months ago

As there has not been any response in 21 days, this issue has been automatically marked as stale. At OP: Please either close this issue or keep it active It will be closed in 7 days if no further activity occurs.

github-actions[bot] commented 7 months ago

As there has not been any response in 28 days, this issue will be closed. @ OP: If this issue is solved post what fixed it for you. If it is not solved, request to get this opened again.

Pirionfr commented 1 month ago

up

Smanar commented 1 month ago

Hello, can you try the DDF too ? Now with nthe DDF bundle this step is easier, you just need the 0.27 version.