dresden-elektronik / deconz-rest-plugin

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

BCM500DS-TYZ-22 support #5960

Closed Pherax closed 2 years ago

Pherax commented 2 years ago

Device

Screenshots

Basic

image

image

Groups

image

Scenes

image

Other clusters that are not mentioned above

I am about to receive this device (do not have it yet). it is already integrated in zha and zigbee2mqtt

https://github.com/zigpy/zha-device-handlers/issues/1294

https://www.zigbee2mqtt.io/devices/TS0601_cover.html

Mimiix commented 2 years ago

Hi,

If you aren't able to provide screenshots, it's hard to implement the device.

I'll add a label for now. Please add screenshots when you have it.

Kind regards,

Pherax commented 2 years ago

I have updated the start post with the requested screenshots.

Pherax commented 2 years ago

Hi,

If you aren't able to provide screenshots, it's hard to implement the device.

I'll add a label for now. Please add screenshots when you have it.

Kind regards,

when will you remove the labels?

Mimiix commented 2 years ago

HI,

I missed your previous post somehow. Sorry!

I've removed them.

Kind regards,

Mimiix commented 2 years ago

Can you please post a screen of the cluster list on the device?

Pherax commented 2 years ago

I do not know what that is, is it this? image

Mimiix commented 2 years ago

Yes :)

@smanar can this be done with a DDF?

Smanar commented 2 years ago

Not yet, sorry, we are finishing the DDF for TRV, if this one work will do same for all other device. But there is probably a new issue ATM on return from tuya device, even just reading a temperature is broken, I m not sure, I m asking to manup to be sure.

github-actions[bot] commented 2 years 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 2 years 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.

Schloerhome commented 2 years ago

Hi any update on this please ? Got the same device

patrusco commented 1 year ago

Hi all, I have the same device and would be happy to help with testing @Pherax can you help ?

Smanar commented 1 year ago

The support for tuya covering is not possible ATM with DDF.

patrusco commented 1 year ago

The support for tuya covering is not possible ATM with DDF. I do see the device but identified as a switch. I was able to use iobroker to close the curtain but opening would be all I require more to get me going with my planned automation..

below the config I got after discovery

{ "1": { "etag": "e343140db698b628c616c3d53104e192", "hascolor": false, "lastannounced": null, "lastseen": "2023-05-09T17:41Z", "manufacturername": "dresden elektronik", "modelid": "RaspBee II", "name": "Configuration tool 1", "state": { "reachable": true }, "swversion": "0x26780700", "type": "Configuration tool", "uniqueid": "00:21:2e:ff:ff:08:b7:a3-01" }, "2": { "capabilities": { "alerts": [ "none", "select", "lselect" ] }, "config": { "groups": [ "0", "1" ] }, "etag": "3f33b981c18366c84b449f59ea1b3a26", "hascolor": false, "lastannounced": null, "lastseen": "2023-05-09T17:40Z", "manufacturername": "_TZE200_rmymn92d", "modelid": "TS0601", "name": "Smart plug 2", "state": { "alert": "none", "on": false, "reachable": true }, "swversion": null, "type": "Smart plug", "uniqueid": "a4:c1:38:2e:8b:59:5b:30-01" } }

patrusco commented 1 year ago

The support for tuya covering is not possible ATM with DDF.

It was possible with the standard discovery above to move the curtain in one direction. So does it mean that this is still not possible? Im not an expert here but one function seams to work so I would assume it is possible to correct the recognition and have the device working? thanks for your help!

Smanar commented 1 year ago

It's not possible to use custom request for covering and more for Tuya one. It's perhaps possible with this PR https://github.com/dresden-elektronik/deconz-rest-plugin/pull/6936/files#diff-75257ab83b06c4302e62c9688cd9d6da01b7b773c5a24a436330464d5badc906R1874 but it's something new, never tried yet.

We can make a fast try, if you can share to me the autogenerated DDF (even uncomplete), right clic on the node, "edit DDF" and you can find it in the "preview" tab.

patrusco commented 1 year ago

Thanks, can you guide me to a "how to" install this? I'm unfortunately not experienced at this point.

Smanar commented 1 year ago

If you can share to me the autogenerated DDF (even uncomplete) we will be able to test a code.

To get the autogenerated DDF it's easy, right clic on the node, "edit DDF" and you can find it in the "preview" tab. This step is fast. You can save the file if you want (but if you do that, remember the path)

Later will be harder to use the new one, what is your OS ?

patrusco commented 1 year ago

Thanks, happy to do so but how do I share a DDF? I have a phoscon gateway where I'm able to login with ssh. what would be the steps required to get you the DDF?

Smanar commented 1 year ago

Ha yep, we can have a problem ^^, you need the GUI to do that. What is your OS ?

patrusco commented 1 year ago

I'm running MAC OS on a Macbook Pro but I got windows VMs and docker containers if that helps..

Smanar commented 1 year ago

And where is running deconz ? It can be easy on some OS (Embed vnc client like in the HA OS), for other can need to use X-fowarding and it's not something easy.

To know if you have an easy way to access GUI else I can try to make a DDF from scratch, so you will just need to install it.

patrusco commented 1 year ago

I'm running deconz as part of IOBroker which runs as part of a docker on my synology

Smanar commented 1 year ago

Ok So I think you are using the official docker image .

Can try this prototype

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZE200_rmymn92d",
  "modelid": "TS0601",
  "product": "BCM500DS-TYZ-22 covering",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_WINDOW_COVERING_DEVICE",
      "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"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "state/on",
          "parse": {"fn": "tuya", "dpid": 1, "eval": "Item.val = Attr.val == 0x01;" },
          "write": {"fn": "tuya", "dpid": 1, "dt": "0x30", "eval": "Item.val == 1 ? 0x01 : 0x02;"},
          "read": {"fn": "tuya"}
        },
        {
          "name": "state/reachable"
        }
      ]
    }
  ],
  "bindings": [
  ]
}

It will support only "state/on" to open/close the covering. This one need to work, if yes you can replace "state/on" by "state/open", then delete the device and re-include it for it use the new DDF. But not sure it will work with "state/open".

Command can be reversed, it's just for test.

patrusco commented 1 year ago

Thanks, great! .. but where do I put this, sorry for the question but I never did edit the .json before.. I assume somewhere here:

pi@phoscon:/usr/share/deCONZ/devices/tuya $ ls ih-f001_door_sensor.json _TZ3000TS0207_range_extender.json ih-k009_temp_hum_sensor.json _TZ3000_TS0207_water_leak_sensor.json nous_a1z_smart_plug.json _TZ3000_TS044_4gang_remote.json nous_hum_temp_e6.json _TZ3000_typdpbpg_smart_plug_eu.json rh3040_motion_sensor.json _TZ3000_water_sensor.json TS0043_3gang_remote.json _TZ3000_yd2e749y_temp_hum_sensor.json ts0202_presence_sensor.json _TZE200_2wg5qrjy_valve.json tuya_swversion.js _TZE200_3towulqd_motion_lux_sensor.json tuya_trv_preset.js _TZE200_9cxuhakf_wired_dimmer.json tuya_trv_preset_set.js _TZE200_amp6tsvy_wired_switch_1gang.json _TZ1800_ladpngdx_lild_doorbell.json _TZE200_bjawzodf_hum_temp.json _TZ3000_4fjiwweb_smart_knob_buttons.js _TZE200_bvu2wnxz_trv.json _TZ3000_4fjiwweb_smart_knob.json _TZE200_byzdayie_din_enrgy_meter.json _TZ3000_cehuw1lw_smartplug_EU.json _TZE200_dq1mfjug_smoke_sensor.json _TZ3000_gzvniqjb_din_rail_switch.json _TZE200_dwcarsat_air_sensor.json _TZ3000_i8jfiezr_temp_hum_sensor.json _TZE200_e3oitdyu_smart_dimmer_module.json _TZ3000_itb0omhv_1gang_bat.json _TZE200_hhrtiq0x_nedis_trv.json _TZ3000_jl7qyupf_2gangs_switch_locked.json _TZE200_htnnfasr_water_valve.json _TZ3000_llfaquvp_switch_module.json _TZE200_m9skfctm_smoke_detector.json _TZ3000_pfc7i3kt_smart_switch_3gangs_locked.json _TZE200_myd45weu_soil_sensor.json _TZ3000_qewo8dlz_wired_switch_3gangs.json _TZE200_pay2byax_openclose_sensor.json _TZ3000_rco1yzb1_switch.json _TZE200_thbr5z34_awowtrv.json _TZ3000_TS0011_1gang_switch_module.json _TZE200_TS0601_humidity_temp.json _TZ3000_TS0042_2gang_remote.json _TZE200_TS0601_mmWave_Radar.json _TZ3000_TS011F_PowerStrip.json ZY-M100_human_breathing_presence.json _TZ3000_TS0203_door_sensor.json pi@phoscon:/usr/share/deCONZ/devices/tuya $

Smanar commented 1 year ago

On the official docker image, you just need to put your DDF file in the /opt/deCONZ/devices folder https://github.com/deconz-community/deconz-docker/issues/163

Just create a new file called what_you_want.json with the DDF contain.

patrusco commented 1 year ago

Hey @Smanar, I was able to install the DDF and re-discovered the device. Unfortunately I'm not able to steer anything but I did get a status back if the device moves (on argument goes from "true" to "false"). any other thing I can try?

Smanar commented 1 year ago

(on argument goes from "true" to "false"

It's "state/on" ? How are you trying to move it ? using direclty the API or using third app ?

With API and a console

curl -H 'Content-Type: application/json' -X PUT -d '{"on":false}' http://IP:PORT/api/API_KEY/lights/ID/state

It's hard to get logs on an headless OS, but how many devices have you ? it's your dev environnement ?

patrusco commented 1 year ago

I move it by using iobrokers objects where I can read and write(screenshot attached). yes it is my environment. the curl command I can not execute on the iobroker level I guess or I need to get hold on the API key which must be somewhere..I try to figure that out..

Bildschirmfoto 2023-06-25 um 16 30 09
Smanar commented 1 year ago

On your picture you are on the "alert" field, and this one is removed on the test DDF, but yes it need to work too. You are sure you are on the good field ? you haven't log to see the send request by iobrokers ?

          "parse": {"fn": "tuya", "dpid": 1, "eval": "Item.val = Attr.val == 0x01;" },
          "write": {"fn": "tuya", "dpid": 1, "dt": "0x30", "eval": "Item.val == 1 ? 0x01 : 0x02;"},

The return is handled by the "parse" part, and if this one is working, I don't see why the "write" part is not working. I m using the same dpid, the dt is good too (enum), and the value need to be good at least for 1 side.

patrusco commented 1 year ago

iobroker/deconz-module creates the elements automatically based on what's comming from my phoscon gateway. On the phoscon, I was able to build your DDF. I think I can confirm that since I see the correct label "window covering device" within iobroker, but don't ask me where the alert is comming from ;).. I do still have the initial DDF which resides within :/usr/share/deCONZ/devices/tuya,. I have not changed anything there. might this also be used in parallel to your DDF?

I have put the deconz module in iobroker into debug mode. I can see the following message:

`

  Code 400: Bad request set light state 2: [{"error":{"address":"/lights/2/state","description":"body contains invalid JSON","type":2}}]

`

In addition I was able to execute your command above with the following result

curl -H 'Content-Type: application/json' -X PUT -d '{"on":false}' http://IP:PORT/api/API_KEY/lights/ID/state

[{"success":{"/lights/2/state/open":true}}]

Smanar commented 1 year ago

body contains invalid JSON

There is something bad in the request, but this part happen before the DDF, Can be iobroker that make it.

In addition I was able to execute your command above with the following result

And the covering don't move ? can try with true and false ?

patrusco commented 1 year ago

And the covering don't move ? can try with true and false ?

unfortunately not. no movement.. is there any other thing I can try to send?

some more additional observations i made: In iobroker I do see some websocket-logs if i press the button on the curtain motor so that it moves. Whenever there is movement (by controlling the motor on the remote) I see "on: false" which goes back to "on: true" after the movement. there is a websocket message following and when I stop the motor, there is another (start id:2, stop id:1)

anything you can do with this?

`

2023-06-26 19:19:41.909 - debug: deconz.0 (23339) on: false

2023-06-26 19:19:41.913 - debug: deconz.0 (23339) reachable: true 2023-06-26 19:19:43.185 - debug: deconz.0 (23339) Websocket message: {"e":"changed","id":"2","r":"lights","state":{"on":true,"reachable":true},"t":"event","uniqueid":"a4:c1:38:2e:8b:59:5b:30-01"} 2023-06-26 19:19:43.186 - debug: deconz.0 (23339) Event has state-tag 2023-06-26 19:19:43.187 - debug: deconz.0 (23339) Websocket message: {"e":"changed","id":"1","r":"groups","state":{"all_on":false,"any_on":true},"t":"event"}

2023-06-26 19:19:43.226 - debug: deconz.0 (23339) Code 200: Request succeded get group attributes 1: {"action":{"alert":"none","bri":127,"colormode":"hs","ct":0,"effect":"none","hue":0,"on":false,"sat":127,"scene":null,"xy":[0,0]},"devicemembership":[],"etag":"139480c2ae3f6db16318b6aff018c380","id":"1","lights":["3","4","2"],"name":"Kino","scenes":[{"id":"1","lightcount":2,"name":"Kino ON","transitiontime":10},{"id":"2","lightcount":2,"name":"Kino OFF","transitiontime":10}],"state":{"all_on":false,"any_on":true},"type":"LightGroup"}

2023-06-26 19:19:43.228 - debug: deconz.0 (23339) on: true

`

Smanar commented 1 year ago

I see "on: false" which goes back to "on: true" after the movement

Can be my fault, on the code I m using 2 way, the dpid 0x01 (the state, apparently not reliable) or 0x02 (going to position) and 0x03 (position reached). Other thing your device need to reverse the position return, and it's based on position so you have 1 closed position and 99 open, the value will change only on full closed or full open. Perhaps better idea to use

"parse": {"fn": "tuya", "dpid": 1, "eval": "Item.val = Attr.val != 0x01;" },

or

"parse": {"fn": "tuya", "dpid": 3, "eval": "Item.val = Attr.val < 5;" },

This is for return, for command send

Tuya covering use thoses dpid for movement

How many device have you ? There is a way to run deconz on debug mode on the docker, can be usefull to catch the log when deconz make the request to see what is missing.

Edit :

Ha ^^, I have see something strange

curl -H 'Content-Type: application/json' -X PUT -d '{"on":false}' http://IP:PORT/api/API_KEY/lights/ID/state

[{"success":{"/lights/2/state/open":true}}]

You are using "state/on" but you have in the response "state/open" and to prevent that, I m using only "state/on" on the DDF to prevent problem with state/open Can be from deconz, state/on is deprecated for covering, are you sure for the request ? If yes can you try with a new DDF, the same one but replacing $TYPE_WINDOW_COVERING_DEVICE by $TYPE_ON_OFF_LIGHT to prevent deconz bypass covering request.

The device will be reconised as light, but we can be sure deconz will use state/on (there is no state/open" for light)

patrusco commented 1 year ago

on the curl command above, yes this is what I'm getting back. So what do you suggest I should do? Just to be sure we are on the same page:

regarding your parse command changes, what would be the fastest way to try this out? I assume this would be a change on the phoscon gateway / deconz instance? Can I change the DDF without re-learning the device? this took me about 40min before it finally was detected. Thanks!

Smanar commented 1 year ago

40 mn ? It's faster with DDF, because deconz not have to guess what is the device.

If you have the GUI there is a command "hot reload" on the DDF editor. Else you can just edit the DDF and restart deconz. But I m not sure the DDF can update the "type" without a re-inclusion.

the same one but replacing $TYPE_WINDOW_COVERING_DEVICE by $TYPE_ON_OFF_LIGHT

For the "parse" test, I m sure, just a deconz restart and he will use the new command, but the "type" change will have more impact, to test if we can send request to the device using DDF

patrusco commented 1 year ago

I still don't know about a GUI in my setup (deconz on iobroker and on phoscon device). How can I start such a gui? I do have the phoscon.app http but this is not what you are talking about, right? Can I install something on my mac to do your modifications?

can you tell me again what I need to edit and test based on your input above. edit the .json on the phoscon? if so, can you send me the code which I need to replace the old with?

thanks!

Smanar commented 1 year ago

You need a desktop environnement or use VNC "stuff" to have the GUI and yes the web app is another thing.

https://github.com/dresden-elektronik/deconz-rest-plugin/wiki/Access-deCONZ-GUI-in-headless-setups

But it's definitively not something easy on docker, and can have new problem, for the moment I think it's better to avoid that.

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZE200_rmymn92d",
  "modelid": "TS0601",
  "product": "BCM500DS-TYZ-22 covering",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_ON_OFF_LIGHT",
      "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"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "state/on",
          "parse": {"fn": "tuya", "dpid": 1, "eval": "Item.val = Attr.val != 0x01;" }
          "write": {"fn": "tuya", "dpid": 1, "dt": "0x30", "eval": "Item.val == 1 ? 0x01 : 0x02;"},
          "read": {"fn": "tuya"}
        },
        {
          "name": "state/reachable"
        }
      ]
    }
  ],
  "bindings": [
  ]
}

On this DDF you have 2 modifcation, the one for the type (will replace the covering by a on/off device) and one to reverse the state/on return.

But not sure the deconz restart will be enought for the type change.

patrusco commented 1 year ago

awesome!! success!! finally I got some movement If I send this call, the curtain closes. if I send a true, it will stop closing. I can not open the curtain at this point

curl -H 'Content-Type: application/json' -X PUT -d '{"on":false}' http://192.168..../api/..../lights/2/state

...I can steer the same thing on iobroker now.. I just have changed the code as per your DDF above without any other thing (no additional modification)..

How do I get to open it? I'm excited now ;) ps: reboot was good enough to get this working ..

Smanar commented 1 year ago

Tuya covering use thoses dpid for movement

"write": {"fn": "tuya", "dpid": 1, "dt": "0x30", "eval": "Item.val == 1 ? 0x01 : 0x02;"},

So If I m right if you send a true value (=1) it send the command 0x01 so the stop else it send the command 0x02 the close. Can try

"write": {"fn": "tuya", "dpid": 1, "dt": "0x30", "eval": "Item.val == 1 ? 0x02 : 0x00;"},

For the return

"parse": {"fn": "tuya", "dpid": 1, "eval": "Item.val = Attr.val != 0x00;" }

Perhaps need to use 0x02 instead of 0x00, but your device is reversed, and the value need to change only on full closed (even just open as 2 % is open), so can make try to find the good value

It's a good new, it mean we can do something using the DDF, but I think will be harder to use open and lift without c++ code edition, but at least the device will be usable by you (using "on" and "bri")

Next step will be set level position.

patrusco commented 1 year ago

Great!

With the code below, I'm able now to close it with "true" and open it with "false". And that works also from iobroker side. I did change the parse argument from "Attr.val ==" to "Attr.val !=" in addition to make "true" the close command

observation: on iobroker I do see return of "true" once the curtain has fully opened. So the value to steer is also the value for a status? strange, but again I'm learning ;)

what next ?

{ "name": "state/on", "parse": {"fn": "tuya", "dpid": 1, "eval": "Item.val = Attr.val != 0x00;" }, "write": {"fn": "tuya", "dpid": 1, "dt": "0x30", "eval": "Item.val == 1 ? 0x02 : 0x00;"}, "read": {"fn": "tuya"} },

Smanar commented 1 year ago

The deconz rule is

shutter FULL closed
on = true
bri = 255
open = false
lift = 100%

So the command is good (the "write") > I'm able now to close it with "true" and open it with "false" But the return is reversed (the parse) > "true" once the curtain has fully opened You need to reverse the "parse".

Now the set level. Tuya device use value from 0 to 100 on the dpid 0x02, we will use state/bri that work with value 0 to 255, so need a little convertion.

        {
          "name": "state/bri",
          "parse": {"fn": "tuya", "dpid": 2, "eval": "Item.val = (Attr.val / 100.0) * 254.0;"},
          "write": {"fn": "tuya", "dpid": 2, "dt": "0x2b", "eval": "(Item.val / 254.0) * 100.0;"},
          "read": {"fn": "none"}
        }

Can be reversed, sorry too much random on tuya.

Remember this DDF is a "unofficial hack", as on/bri are deprecated, I need to take a look later to see how to use open/lift.

Edit:

I have found my old code "covering_new", but I never found tester ^^, do you have a linux machine with full OS by hazard ?

patrusco commented 1 year ago

Okey! Now I'm able to move the curtan to a specific position. Below the example where I was able to set "bri" on 175 and tue curtain moves to 68% (also visible in IOBroker). I'm not able to change the % this seems just to be a status but not for control, right?

Bildschirmfoto 2023-07-07 um 19 51 44

regarding linux, I can build one if you like? but the function we got now is already great since I have control in both directions and I'm able to set the position, thats awesome!

Smanar commented 1 year ago

IDK, this is from your third app, 68% = 175 (max is 255) Deconz use only the numeric value.

regarding linux, I can build one if you like? but the function we got now is already great since I have control in both directions and I'm able to set the position, thats awesome!

In fact this DDF is a "hack" we are using bri/on from a "light" device, we need to use lift/open from a "covering" device. One day you will have issue with this DDF.

I have a code modification that add this feature to DDF, but hard to find testers. You need a linux OS with complete OS to test code modification. I can explain how to do if you want to make a try ?

patrusco commented 1 year ago

sure! tell me what linux you prefer and I will get a VM built to test. Please understand that I'm only able to build VM's which have remote-access to my phoscon gateway, so no direct attached zigbee stuff, but if that sufficient I'm happy to help "back" and give it a try

Smanar commented 1 year ago

Ha, so we have a problem ^^. I don't need your whole network, but the conbee need to be pluged on the VM, so it will impact your production network (even just for 10 mn tests)