Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roller shutters recognized as ir_remote_sensors #228

Closed
mihsu81 opened this issue Aug 31, 2022 · 10 comments
Closed

Roller shutters recognized as ir_remote_sensors #228

mihsu81 opened this issue Aug 31, 2022 · 10 comments

Comments

@mihsu81
Copy link
Contributor

mihsu81 commented Aug 31, 2022

Hi @make-all,

Thank you for your integration.

My roller shutters are recognized as ir_remote_sensors and log a warning in HA.

I've pasted below the details of the device from Tuya Developer.

image

Log Details (WARNING)
This error originated from a custom integration.

Logger: custom_components.tuya_local.config_flow
Source: custom_components/tuya_local/config_flow.py:35
Integration: Tuya Local (documentation, issues)
First occurred: 10:33:58 (4 occurrences)
Last logged: 10:35:01

Device matches ir_remote_sensors with quality of 17%. DPS: {'101': '2', '102': 100, '103': True, '104': '1', '105': True, '106': '0', '107': '1', '108': '1', '110': 'a', '111': True, '112': 100, '113': '5', 'updated_at': 1661931238.0216303}
Report this to https://github.com/make-all/tuya-local/issues/
Device matches ir_remote_sensors with quality of 17%. DPS: {'101': '2', '102': 100, '103': True, '104': '1', '105': True, '106': '0', '107': '1', '108': '1', '110': 'a', '111': True, '112': 100, '113': '5', 'updated_at': 1661931301.3950877}
Code					Type			Values
control					Enum			{
										"range": [
											"open",
											"stop",
											"close"
										]
										}

percent_control			Integer			{
										"unit": "%",
										"min": 0,
										"max": 100,
										"scale": 0,
										"step": 1
										}

control_back			Boolean			"{true,false}"

border					Enum			{
										"range": [
											"1",
											"2",
											"3",
											"4",
											"5"
										]
										}

curtain_hand			Boolean			"{true,false}"

state					Enum			{
										"range": [
											"0",
											"1",
											"2",
											"3"
										]
										}

curtain_AC_control		Enum			{
										"range": [
											"1",
											"2",
											"3",
											"4"
										]
										}

curtain_DC_control		Enum			{
										"range": [
											"1",
											"2",
											"3",
											"4"
										]
										}

curtain_type			String			{
										"maxlen": 255
										}

report					String			{
										"maxlen": 255
										}

currenPosition			Integer			{
										"unit": "",
										"min": 0,
										"max": 100,
										"scale": 0,
										"step": 1
										}

style					Enum			{
										"range": [
											"0",
											"1",
											"2",
											"3",
											"4",
											"5",
											"6",
											"7",
											"8",
											"9",
											"10",
											"11"
										]
										}
@make-all
Copy link
Owner

The Tuya Developer portal has a function in the API Explorer, under "Device Control" in the first pane, the last "Get Device Specification Attribute" function. That one returns the local dp indexes for the above list of functions and status.

Also, it looks like there are more datapoints there than are in the API docs. You can find information about the others by clicking on your Cloud Project, Devices, and selecting your Device (you may need to Link Tuya App Account if it is not showing in the list). Then click on Debug Device, and Device Logs. Open the Browser's Developer Tools menu on the Network page, and in the "Select DP ID" dropdown at the top, select each of the options that did not appear in the API Explorer docs and press search, then look in the Developer Tools window for a "list" request, the "code" parameter is the local dpId for that function (the name may be in Chinese, but Google translate can give some idea of what it might be).

@make-all
Copy link
Owner

If you paired directly to your Cloud Project using tuya-cli, you may see "Details" instead of "Debug Device" in the Device page. In that case you can re-pair the device using the Tuya or Smart Life app (the local key will need updating, but you can find it in the developer portal) that is linked to your iot.tuya.com account (Link Tuya App Account on that Cloud Project screen) to get the more powerful Debug Device option.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Aug 31, 2022

Thanks @make-all. Here are the details from "Get Device Specification Attribute" as well as "Get Device Specification" which return all the details without having to go in Developer Tools.

{
  "result": {
    "category": "cl",
    "functions": [
      {
        "code": "control",
        "dp_id": 101,
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"stop\",\"close\"]}"
      },
      {
        "code": "percent_control",
        "dp_id": 102,
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "control_back",
        "dp_id": 103,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "border",
        "dp_id": 104,
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\",\"5\"]}"
      },
      {
        "code": "curtain_hand",
        "dp_id": 105,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "state",
        "dp_id": 106,
        "type": "Enum",
        "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\"]}"
      },
      {
        "code": "curtain_AC_control",
        "dp_id": 107,
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\"]}"
      },
      {
        "code": "curtain_DC_control",
        "dp_id": 108,
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\"]}"
      },
      {
        "code": "curtain_type",
        "dp_id": 109,
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "report",
        "dp_id": 110,
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "currenPosition",
        "dp_id": 112,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "style",
        "dp_id": 113,
        "type": "Enum",
        "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\"]}"
      }
    ],
    "status": [
      {
        "code": "control",
        "dp_id": 101,
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"stop\",\"close\"]}"
      },
      {
        "code": "percent_control",
        "dp_id": 102,
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "control_back",
        "dp_id": 103,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "border",
        "dp_id": 104,
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\",\"5\"]}"
      },
      {
        "code": "curtain_hand",
        "dp_id": 105,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "state",
        "dp_id": 106,
        "type": "Enum",
        "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\"]}"
      },
      {
        "code": "curtain_AC_control",
        "dp_id": 107,
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\"]}"
      },
      {
        "code": "curtain_DC_control",
        "dp_id": 108,
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\"]}"
      },
      {
        "code": "curtain_type",
        "dp_id": 109,
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "report",
        "dp_id": 110,
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "borderState",
        "dp_id": 111,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "currenPosition",
        "dp_id": 112,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "style",
        "dp_id": 113,
        "type": "Enum",
        "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\"]}"
      }
    ]
  },
  "success": true,
  "t": 1661938633704,
  "tid": "7e7dbb46291011ed9cadaa5778b32c34"
}
{
  "result": {
    "category": "cl",
    "functions": [
      {
        "code": "control",
        "lang_config": {
          "close": "Down",
          "open": "Up",
          "stop": "Pause"
        },
        "name": "Curtain control",
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"stop\",\"close\"]}"
      },
      {
        "code": "percent_control",
        "lang_config": {
          "unit": "%"
        },
        "name": "BestPosition",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "control_back",
        "lang_config": {
          "false": "negative direction off",
          "true": "Default orientation"
        },
        "name": "Direction Setting",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "border",
        "lang_config": {
          "1": "Upper limit setting",
          "2": "Upper limit remove",
          "3": "Lower limit setting",
          "4": "Lower limit remove",
          "5": "Upper/lower limit remove"
        },
        "name": "Border Setting",
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\",\"5\"]}"
      },
      {
        "code": "curtain_hand",
        "lang_config": {
          "false": "",
          "true": ""
        },
        "name": "电机手拉",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "state",
        "lang_config": {
          "0": "",
          "1": "",
          "2": "",
          "3": ""
        },
        "name": "电机状态",
        "type": "Enum",
        "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\"]}"
      },
      {
        "code": "curtain_AC_control",
        "lang_config": {
          "1": "",
          "2": "",
          "3": "",
          "4": ""
        },
        "name": "电机强电控制方式",
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\"]}"
      },
      {
        "code": "curtain_DC_control",
        "lang_config": {
          "1": "",
          "2": "",
          "3": "",
          "4": ""
        },
        "name": "电机弱电控制方式",
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\"]}"
      },
      {
        "code": "curtain_type",
        "lang_config": {
          "unit": ""
        },
        "name": "电机类型",
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "report",
        "lang_config": {
          "unit": ""
        },
        "name": "电机信息上报",
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "currenPosition",
        "lang_config": {
          "unit": ""
        },
        "name": "查询电机当前位置",
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "style",
        "lang_config": {
          "0": "Sihousette blind",
          "1": "Roman blind",
          "2": "Roller blind",
          "3": "Soft blind",
          "4": "Roller shutter",
          "5": "Honeycomb blind",
          "6": "Pleated blind",
          "7": "Roller door",
          "8": "Awning",
          "9": "Curtain",
          "10": "Roman pole",
          "11": ""
        },
        "name": "Venetian blind",
        "type": "Enum",
        "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\"]}"
      }
    ],
    "status": [
      {
        "code": "control",
        "lang_config": {
          "close": "Down",
          "open": "Up",
          "stop": "Pause"
        },
        "name": "Curtain control",
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"stop\",\"close\"]}"
      },
      {
        "code": "percent_control",
        "lang_config": {
          "unit": "%"
        },
        "name": "BestPosition",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "control_back",
        "lang_config": {
          "false": "negative direction off",
          "true": "Default orientation"
        },
        "name": "Direction Setting",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "border",
        "lang_config": {
          "1": "Upper limit setting",
          "2": "Upper limit remove",
          "3": "Lower limit setting",
          "4": "Lower limit remove",
          "5": "Upper/lower limit remove"
        },
        "name": "Border Setting",
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\",\"5\"]}"
      },
      {
        "code": "curtain_hand",
        "lang_config": {
          "false": "",
          "true": ""
        },
        "name": "电机手拉",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "state",
        "lang_config": {
          "0": "",
          "1": "",
          "2": "",
          "3": ""
        },
        "name": "电机状态",
        "type": "Enum",
        "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\"]}"
      },
      {
        "code": "curtain_AC_control",
        "lang_config": {
          "1": "",
          "2": "",
          "3": "",
          "4": ""
        },
        "name": "电机强电控制方式",
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\"]}"
      },
      {
        "code": "curtain_DC_control",
        "lang_config": {
          "1": "",
          "2": "",
          "3": "",
          "4": ""
        },
        "name": "电机弱电控制方式",
        "type": "Enum",
        "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\"]}"
      },
      {
        "code": "curtain_type",
        "lang_config": {
          "unit": ""
        },
        "name": "电机类型",
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "report",
        "lang_config": {
          "unit": ""
        },
        "name": "电机信息上报",
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "borderState",
        "lang_config": {
          "false": "",
          "true": ""
        },
        "name": "电机行程状态",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "currenPosition",
        "lang_config": {
          "unit": ""
        },
        "name": "查询电机当前位置",
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "style",
        "lang_config": {
          "0": "Sihousette blind",
          "1": "Roman blind",
          "2": "Roller blind",
          "3": "Soft blind",
          "4": "Roller shutter",
          "5": "Honeycomb blind",
          "6": "Pleated blind",
          "7": "Roller door",
          "8": "Awning",
          "9": "Curtain",
          "10": "Roman pole",
          "11": ""
        },
        "name": "Venetian blind",
        "type": "Enum",
        "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\"]}"
      }
    ]
  },
  "success": true,
  "t": 1661938341151,
  "tid": "d0168dc6290f11ed847d56ce79da263b"
}

@make-all
Copy link
Owner

Thanks, I hadn't noticed before that the Get Device Specification returns more details about the enum values, which is useful when they are not descriptive like this.

Do you have a link to a user manual, or even just a manufacturer/model name I can use for the config file naming?

@mihsu81
Copy link
Contributor Author

mihsu81 commented Aug 31, 2022

I'm glad I could contribute in some way. :)
They're called CFT but that's just the rebranding of the Chinese OEM model for a Romanian company called Comfortex.
https://www.facebook.com/ComfortexRomania/posts/1045815262149584?_rdr
This is what I got from the Tuya cloud integration:

    "name": "Kitchen Shutters",
    "model": "WSERD30-T-WIFI/WSER40-Wifi",
    "category": "cl",
    "product_id": "c4hBLohzUgxULw5a",
    "product_name": "WiFi Tubular Motor",

@make-all make-all added the new device Unsupported device label Sep 1, 2022
make-all added a commit that referenced this issue Sep 8, 2022
Issue #228

- cover: add support for "reversed" dp (control_back in tuya docs),
         assuming the purpose is to indicate/control when the
         direction of open/close is reversed.
@make-all make-all added awaiting confirmation Wating for confirmation the issue is solved unreleased Will be in next release labels Sep 8, 2022
@mihsu81
Copy link
Contributor Author

mihsu81 commented Sep 13, 2022

Thanks a lot for the implementation and sorry for the delay testing it.

Some of the values of the DPs should be adjusted. I've added comments in the PR and also added them below.

Also, the implementation of the controls is a bit laggy. Sometimes it takes 2-3 seconds to get the command. This doesn't happen with the Tuya cloud integration or localtuya.

And the device becomes unavailable at times while controlling it. I've disabled all the other Tuya related integrations and made sure the Tuya App is not open on my mobile.

Additionally, the implementation doesn't seem to take into account that DP 102 sets the position and DP 112 reads the current position. The cover entity only displays the set position, not the current one.

P.S. Would it be possible to allow controlling the cover only when DP 111 (Has Border) is set to true? Otherwise, the motor would turn until it breaks the shutter.

    - id: 101
      type: string
      name: control
      mapping:
        - dps_val: "0"
          value: open
        - dps_val: "2"
          value: stop
        - dps_val: "1"
          value: close
  - entity: select
    category: config
    name: Style
    icon: "mdi:blinds-horizontal"
    dps:
      - id: 113
        type: string
        name: option
        mapping:
          - dps_val: "0"
            value: Venetian blind
          - dps_val: "1"
            value: Sihousette blind
          - dps_val: "2"
            value: Roman blind
          - dps_val: "3"
            value: Roller blind
          - dps_val: "4"
            value: Soft blind
          - dps_val: "5"
            value: Roller shutter
          - dps_val: "6"
            value: Honeycomb blind
          - dps_val: "7"
            value: Pleated blind
          - dps_val: "8"
            value: Roller door
          - dps_val: "9"
            value: Awning
          - dps_val: "10"
            value: Curtain
          - dps_val: "11"
            value: Roman pole

make-all added a commit that referenced this issue Sep 18, 2022
- swap stop and close command values.  Order does not match iot.tuya.com docs
- add Venetian blinds at start and remove Other at end of style values.
- restrict open and closed commands to when border is set to avoid destroying blinds. position will still be available for fine setting at user's risk.

Issue #228
@make-all make-all removed new device Unsupported device unreleased Will be in next release labels Sep 19, 2022
@make-all
Copy link
Owner

Included in 0.19.0 release along with the suggested adjustments.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Sep 20, 2022

@make-all the devices become unavailable after 2-3 commands and the only way to make them available again is to restart HA.
I've pinged the device and didn't see any drops during operation or outside of it, I've disabled the integrations localtuya and Tuya cloud and made sure the Tuya app is closed on the phone.
If I try to reconfigure the integration for a specific device, it says it is unreachable.

@mihsu81
Copy link
Contributor Author

mihsu81 commented Sep 20, 2022

@make-all I've just realized that the command which seems to break the integration is the "stop" command even if it is the first command I send.
A few seconds after I press "stop", the cover entity becomes unavailable and some seconds later the rest of the entities become unavailable.
The stop command does have the expected effect of stopping the motor from moving, but no other command works, and the entity becomes unavailable.
The only error I see is:

This error originated from a custom integration.

Logger: custom_components.tuya_local.device
Source: custom_components/tuya_local/device.py:132
Integration: Tuya Local (documentation, issues)
First occurred: 20:12:42 (2 occurrences)
Last logged: 20:12:55

Failed to refresh device state for Kitchen Shutter.

@make-all
Copy link
Owner

make-all commented Sep 26, 2022

There seems to be a general issue with the tinytuya 1.6.6 library. I have reverted to 1.6.5 and released tuya-local 0.19.2. Hopefully this will work better (recover after devices go offline for a period after a command).

@make-all make-all removed the awaiting confirmation Wating for confirmation the issue is solved label Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants