dresden-elektronik / deconz-rest-plugin

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

to invert the shutter state #7737

Closed sanluca closed 4 months ago

sanluca commented 4 months ago

Is there already an existing issue for this?

Product name

roller shutter

Manufacturer

_TZ3000_iaxvag8w

Model identifier

TS130F

Device type to add

Other

Node info

I'm using a _TZ3000_iaxvag8w roller shutter module produced by TS130F. However, I'm facing an issue with OpenHAB. The roller shutter module indicates a fully open state as 100% and a closed state as 0%. Conversely, OpenHAB interprets the states differently: 0% indicates an open shutter and 100% indicates a closed one. Is there a way to invert the state of the Zigbee module? thanks

Endpoints and clusters

.

Basic

basic

Further relevant clusters

Power Configuration

On/Off

Level Control

Color Control

Thermostat

Simple Metering

Electrical Measurement

Any other cluster of relevance/interest

sanluca commented 4 months ago

This is the DDF file

{ "schema": "devcap1.schema.json", "manufacturername": "_TZ3000_iaxvag8w", "modelid": "TS130F", "product": "TS130F", "sleeper": false, "status": "Draft", "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/bri", "description": "The current brightness.", "refresh.interval": 5 }, { "name": "state/lift", "description": "The lift state of a roller blind.", "refresh.interval": 300, "default": 0 }, { "name": "state/on", "description": "True when device is on; false when off.", "refresh.interval": 5 }, { "name": "state/open", "description": "True when open is detected." }, { "name": "state/reachable" } ] } ], "bindings": [ { "bind": "unicast", "src.ep": 1, "dst.ep": 1, "cl": "0x0102", "report": [ { "at": "0x0008", "dt": "0x20", "min": 1, "max": 300, "change": "0x00000001" } ] } ] }

Smanar commented 4 months ago

OpenHAB interprets the states differently: 0% indicates an open shutter and 100% indicates a closed one

Same for deconz ^^

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

Can you try this DDF

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZ3000_iaxvag8w",
  "modelid": "TS130F",
  "product": "TS130F",
  "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",
          "refresh.interval": 86400,
          "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": "state/lift",
          "parse": {
            "at": "0x0008",
            "cl": "0x0102",
            "ep": 5,
            "eval": "Item.val = 100 - Attr.val;",
            "fn": "zcl:attr"
          }
        },
        {
          "name": "state/open",
          "parse": {
            "at": "0x0008",
            "cl": "0x0102",
            "ep": 5,
            "eval": "Item.val = Attr.val > 1",
            "fn": "zcl:attr"
          }
        },
        {
          "name": "state/reachable"
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "dst.ep": 1,
      "cl": "0x0102",
      "report": [
        {
          "at": "0x0008",
          "dt": "0x20",
          "min": 1,
          "max": 300,
          "change": "0x00000001"
        }
      ]
    }
  ]
}

For information;

sanluca commented 4 months ago

I'm trying to find the file to modify it, but the strange thing is that the GUI tells me that the file doesn't exist. How can I do it? I'm attaching screenshots, thanks.

Immagine

sanluca commented 4 months ago

Ok, I managed to do it, I created the file and renamed it as you can see in the screenshot, only that if I do it on Phoscon it doesn't update the status, it always stays closed.

Immagine Immagine2 Immagine3

Smanar commented 4 months ago

On openHAB you probably have a classic OS

All DDF provided directly with deCONZ typically reside in /usr/share/deCONZ/devices/ on a Linux system and are loaded first. However, files residing in the home directory of the user running deCONZ (e.g. /home//.local/share/dresden-elektronik/deCONZ/devices) will override the pre-packaged files to allow users to amend and keep their own files if desired.

This DDF is a new one, so you need to create a text file called what_you_want.json with this contain (in a "devices" folder, the tuya one is perefct).

On your capture it seem fine (the name in editor)

For test, can you try with OpenHAB, it think it have a better suppport than Phoscon for covering.

And BTW I have used the bad ep in my DDF, sorry, have corrected it

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZ3000_iaxvag8w",
  "modelid": "TS130F",
  "product": "TS130F",
  "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",
          "refresh.interval": 86400,
          "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": "state/lift",
          "parse": {
            "at": "0x0008",
            "cl": "0x0102",
            "ep": 1,
            "eval": "Item.val = 100 - Attr.val;",
            "fn": "zcl:attr"
          }
        },
        {
          "name": "state/open",
          "parse": {
            "at": "0x0008",
            "cl": "0x0102",
            "ep": 1,
            "eval": "Item.val = Attr.val > 1",
            "fn": "zcl:attr"
          }
        },
        {
          "name": "state/reachable"
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "dst.ep": 1,
      "cl": "0x0102",
      "report": [
        {
          "at": "0x0008",
          "dt": "0x20",
          "min": 1,
          "max": 300,
          "change": "0x00000001"
        }
      ]
    }
  ]
}
sanluca commented 4 months ago

Perfect, now it works! I use a Linux system (Ubuntu) with OpenHAB 4.1.2, I put the file in the tuya directory, as in the screenshot, now OpenHAB reads the status correctly, and Phoscon also updates, even if it no longer appears closed, but it doesn't matter.

Will this file be added in the new update?

Thank you for your time.

Smanar commented 4 months ago

Np, you have spend more time than me ^^. PR submited here https://github.com/dresden-elektronik/deconz-rest-plugin/pull/7739

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