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

Moes Smart Dimmer Module 1 Gang ZM-105-M #7703

Closed dmichalski closed 2 months ago

dmichalski commented 2 months ago

Is there already an existing issue for this?

Product name

Moes Smart Dimmer Module 1 Gang ZM-105-M

Manufacturer

_TZE204_dcnsggvz

Model identifier

TS0601

Device type to add

Light

Node info

02_node_info

Endpoints and clusters

01_clusters

Basic

grafik

Further relevant clusters

Power Configuration

On/Off

Level Control

Color Control

Thermostat

Simple Metering

Electrical Measurement

Any other cluster of relevance/interest

dmichalski commented 2 months ago

The dimmer is recognized by Phoscon but wrongly identified as a plug instead of a dimmable light. Anything else I can do to get that one added?

Smanar commented 2 months ago

Hello can try this DDF

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZE204_dcnsggvz",
  "modelid": "TS0601",
  "vendor": "$MF_TUYA",
  "product": "I gang dimmer",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_DIMMER_SWITCH",
      "restapi": "/lights",
      "uuid": [
        "$address.ext",
        "0x01"
      ],
      "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"},
           "refresh.interval": 86400
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "state/on",
          "parse": {"fn": "tuya", "dpid": 1, "eval": "Item.val = Attr.val;" },
          "write": {"fn": "tuya", "dpid": 1, "dt": "0x10", "eval": "Item.val == 1 ? 1 : 0;"},
          "read": {"fn": "none"},
        },
        {
          "name": "state/bri",
          "parse": {"fn": "tuya", "dpid": 2, "eval": "Item.val = (Attr.val / 1000.0) * 254.0;"},
          "write": {"fn": "tuya", "dpid": 2, "dt": "0x2b", "eval": "(Item.val / 254.0) * 1000.0;"},
          "read": {"fn": "none"},
        },
        {
          "name": "state/reachable"
        }
      ]
    }
  ]
}

I can be wrong for tuya dpid, have made this DDF with another one.

dmichalski commented 2 months ago

Thanks for the DDF!

Unfortunately I'm not able to get this one working properly. I placed the file inside ~/.local/share/dresden-elektronik/deCONZ/devices and did a systemctl deconz restart. But the dimmer is still recognized as Smart Plug and not as light. Am I missing out on something? Sorry, first time I'm working with DDF.

Btw. is there a way to really edit the DDF in deconz GUI? I see the menu item and can open the edit pane. But it seems to be read only...

Smanar commented 2 months ago

But the dimmer is still recognized as Smart Plug and not as light

The difference will not be visible in deconz, but on the API. Deconz show the reality, it's from the device firmware, but in the API, the device will be reconised as

"type": "$TYPE_DIMMER_SWITCH",

IDK what is your third app ? else can try with phoscon/help/API Information/light

Btw. is there a way to really edit the DDF in deconz GUI? I see the menu item and can open the edit pane. But it seems to be read only

It's possible, but not easier, almost for tuya. But if you select the node and "edit DDF" you need to see your DDF, else something have failed.

dmichalski commented 2 months ago

Ok, nevermind. The JSON above has two trailing "," on the item descriptions which led to an error during the file import. So for future visitors, the following version works like a charm for the Moes dimmer:

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZE204_dcnsggvz",
  "modelid": "TS0601",
  "product": "TS0601",
  "sleeper": false,
  "status": "Gold",
  "path": "/devices/ts0601.json",
  "subdevices": [
    {
      "type": "$TYPE_DIMMER_SWITCH",
      "restapi": "/lights",
      "uuid": [
        "$address.ext",
        "0x01"
      ],
      "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"},
          "refresh.interval": 86400
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "state/on",
          "parse": {"fn": "tuya", "dpid": 1, "eval": "Item.val = Attr.val;" },
          "write": {"fn": "tuya", "dpid": 1, "dt": "0x10", "eval": "Item.val == 1 ? 1 : 0;"},
          "read": {"fn": "none"}
        },
        {
          "name": "state/bri",
          "parse": {"fn": "tuya", "dpid": 2, "eval": "Item.val = (Attr.val / 1000.0) * 254.0;"},
          "write": {"fn": "tuya", "dpid": 2, "dt": "0x2b", "eval": "(Item.val / 254.0) * 1000.0;"},
          "read": {"fn": "none"}
        },
        {
          "name": "state/reachable"
        }
      ]
    }
  ]
}

Thanks again @Smanar!

Smanar commented 2 months ago

Do you want to make a PR to add officialy or want I make it ?

Mimiix commented 2 months ago

Please dont close unless a PR has been merged.

dmichalski commented 2 months ago

Just created the PR. Hope I did everything right...

Smanar commented 2 months ago

For me it's fine, you have a strange error, but I don't see the problem, I m asking.