make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.31k stars 516 forks source link

Request support for doorbell WGH-ML-001 #504

Closed nijel closed 1 year ago

nijel commented 1 year ago

Log Message

Device matches None with quality of 0%. DPS: {"updated_at": 1678177158.7740445, "2": 1, "3": 42, "6": false}
Report this to https://github.com/make-all/tuya-local/issues/

Information about DPS mappings

{
  "result": {
    "category": "wxml",
    "functions": [
      {
        "code": "doorbell_ring_value",
        "dp_id": 2,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":40,\"scale\":0,\"step\":1}"
      },
      {
        "code": "doorbell_volume_value",
        "dp_id": 3,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "alarm_propel_switch",
        "dp_id": 6,
        "type": "Boolean",
        "values": "{}"
      }
    ],
    "status": [
      {
        "code": "doorbell_ring_value",
        "dp_id": 2,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":40,\"scale\":0,\"step\":1}"
      },
      {
        "code": "doorbell_volume_value",
        "dp_id": 3,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "alarm_propel_switch",
        "dp_id": 6,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "doorbell_call",
        "dp_id": 10,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":1,\"max\":255,\"scale\":0,\"step\":1}"
      }
    ]
  },
  "success": true
}

Additional DPs:

5 - alarm message - it triggers when button is pressed 1 - doorbell list data - buttons configuration 7 - disturb data - DND configuration

Product ID

Product id: 26xtgamy3tv1awhl

Information about how the device functions

Sold under many brands, for example https://www.aliexpress.com/item/1005004524467677.html

DP 2 / 3 are configuration options, and they trigger the bell as well. Having DP 2 as a service to trigger via automation is useful (even when the value doesn't change, the bell rings). Integers.

DP 6 toggles notifications via Tuya app. Boolean.

DP 5 is an event that is fired when the button is pressed. There can be multiple (up to 255) buttons linked to the device and the value is base64 encoded UTF-16 name of the button, example payload: AFYAYwBoAG8AZA== translates to Vchod.

DP 10 triggers ring for one of the configured buttons.

DP 1 configures name, ringtone, and volume per button, example payload AgQBAQwBKgD/CgBWAGMAaABvAGQ=, I didn't investigate it.

DP 7 configures DND slots, example payload AP8FKAFo, I didn't investigate it.

Integrating DPs 2 / 3 / 6 seems straightforward, but I fail to see how to expose DP 5 in a usable way. It is only fired when the button is pressed, and it never has a blank value. Exposing this as a normal sensor is not really useful, as the value will change once, and you never get the trigger again.

make-all commented 1 year ago

DP 5 may not be useful in the UI as a sensor, but it could still be useful as an automation trigger.

nijel commented 1 year ago

Yes, that's how I use it now. The problem is that when turned into a sensor, its value doesn't change, and thus the trigger does not happen. Maybe I'm missing something here…

For me, there is a single button paired to the device, so the only value for DP 5 is AFYAYwBoAG8AZA== (what decodes to Vchod, what is the button name given in the Tuya app). As the value doesn't change, Home Assistant ignores the change and does not trigger the event.

If used as sensor, it would need to revert to blank after some (short) time.

make-all commented 1 year ago

Yes, you are probably right. The last value will be retained while it is not sending anything, so it will work once then not work after that if the same value is sent for the next press.

davidwkerr commented 1 year ago

I have HA installed and a couple of these WGH-ML-001 door bells.

However I am only at amateur level in understanding how HA works under the covers.

Is it possible to make the bell ring (from HA)? Could someone please give me some hints or references on how to do this?

I have the devices in tuya local but the UI does not allow me to do anything nor the automations.

Many thanks, David

nijel commented 1 year ago

Setting DP 2 or 3 does make the bell ring. If exposed as choices in HA ( what i believe this integration will do, i haven't yet tested recent changes), you will actually have to change the value to make it emit the event to the bell.

davidwkerr commented 1 year ago

Thank you! It seems to be working!

make-all commented 1 year ago

There should be a siren entity exposing "tone" (dp 2) and volume (dp 3) attributes through the turn_on service, along with a switch for the notifications, and a binary sensor to indicate when it was triggered and sensor to indicate which button triggered it.

davidwkerr commented 1 year ago

The Siren entity seems just what I need because a switch does not pass volume or ringtone . However the localtuya integration does not seem to expose a siren entity.

Do you have suggestions on how to make this appear?

Thanks

make-all commented 1 year ago

localtuya questions do not belong here.

davidwkerr commented 1 year ago

Hm, I'm just trying to get the WGH-ML-001 doorbell to work through localtuya.

However, given I cannot access the Siren entity (which sounds like what I need), I have had success with the number entity and can switch ring tones and bell volume using that and an automation. Thank you.

nijel commented 1 year ago

I finally got to test this. The siren works well, but I don't get the button notifications. No errors in the log, any idea how to easily debug that?

Looking at the commit, is really having both dps 5 and 10 at the single button? How it is supposed to behave?

https://github.com/make-all/tuya-local/commit/81283514823d0c12f990f9a41d2e93f6ee4b4b2c#diff-7bda0d57f674de4317cc070f68d68d3ee16afd4770169379af80774f3686ca62R124

make-all commented 1 year ago

dp 5 is the name, dp 10 is the number of the button that is pressed. Since they are the same item, and the name is probably not easy to work with as it is base64 encoded, the name is just added as an attribute on the sensor for the number of the button that is pressed. If you just want to know that a button is pressed, and don't need to identify it, the binary sensor "Ringing" is probably easier to use. Since these will only change state momentarily, you will probably need to check the Logbook or the History of the entity to see if it is working.

nijel commented 1 year ago

When a button is pressed, only DP 5 is triggered. I've not seen DP 10 to trigger so far. https://github.com/make-all/tuya-local/pull/625 should address this.

svicar commented 1 year ago

hello I am beginer.. I have the same doorbell WGH-ML-001 from aliexpress (the same like on post no#1). When I put ID, IP and local key into tuya local it show me to select: co2_box or feit_dimmer....but none of those two is right..this is door bell. What to do? thank you for help

make-all commented 1 year ago

The original report shows that the device only sends values for dps 2 (integer), 3 (integer) and 6 (boolean).

Both co2_box and feit_dimmer only require dp 2 (integer), so if either dp 3 or 6 is missing, it would still match those.

I need to see the log message to see which dp is missing, then it can be marked optional. Hopefully it is just one, so that this device is still distinguishable from those two other devices automatically.