make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.32k stars 518 forks source link

Request Support Garage door opener #46

Closed myevit closed 2 years ago

myevit commented 3 years ago

I was using homebridge pluging https://github.com/AMoo-Miki/homebridge-tuya-lan/ and it was working great. Can help out with testing

make-all commented 3 years ago

Currently there is no cover support, and I don't have any devices to test that. I think localtuya can support cover devices already, so you might be able to use that.

In any case, there is insufficient information to do anything with this report. To add a new device, I would need details of the device and log messages that show what DPS are returned from the device as a starting point.

bjoerngiese93 commented 2 years ago

That’s enough information @make-all

image

make-all commented 2 years ago

Hi @bjoerngiese93, I assume that is for the curtain device you requested in #69. That information is part of what I need, it tells the possible values that the dps take. But some of the meanings are not clear, specifically mach_operate FZ and ZZ, and what opposite actually means. Also, this seems to be taken from the Tuya Portal, which is documentation for the cloud API. For the local API, the device uses numeric indexes in place of the Code, and I need to know those as well. They can be discovered using tuya-cli if you are familiar with that, or by starting to add the device until it gets to the point where it offers to add a Simple Switch or says no matching device found or some other device that isn't really a match. Then cancel and look in the Home Assistant Logs for the latest warning messages from Tuya Local about the mismatch.

Also brand and model are needed to identify what device this is, as there is no generally no standard for Tuya devces, so this will be unlikely to be a generic curtain that works for other devices as well (or at least we will need to find a few more devices to decide it is - so far only smartplugs seem to have common software that is shared across brands)

make-all commented 2 years ago

Edit: comment removed Sorry, I thought I had found some way to get dps reported inside the app, but it turns out this is fake test devices, not for the actual devices on your network.

make-all commented 2 years ago

I have basically created the cover implementation, now just need to know the dps indexes so I can create a config for testing, so I can test the cover implementation before submitting it. It seems that like switches, Tuya has some standard defined for curtains, but yours seems to be using the options marked as legacy (FZ, ZZ instead of open, close), so I'm not sure the indexes will be the same, as like the switches, they probably reassigned indexes between v1 and v2.

make-all commented 2 years ago

As for garage doors, they have an example for that which is just a series of switches and sensors (no position available). I'll need more details about the device: list of dps, some experimentation to find out what functions they map to, and brand and model info to identify the configuration, as they are likely not to be standardised.

myevit commented 2 years ago

If it will help here are some codes from my Homebridge setup:

[Tuya] Heard back from Garage Door with command 8 [Tuya] eWeLink GarageDoor changed:{"101":true} [Tuya] Heard back from Garage Door with command 8 [Tuya] eWeLink GarageDoor changed:{"101":false}

config:

                   "name": "Garage Door",
                    "type": "GarageDoor",
                    "manufacturer": "eWeLink",
                    "model": "WiFi Switch Garage Door Controller",
                    "id": "xxxxxxxxxxxxx",
                    "key": "xxxxxxxxxxxxx",
                    "dpAction": 1,
                    "dpStatus": 101,
                    "pingTimeout": 2147483,
                    "connectTimeout": 2147483

I was using this wiki to set it up https://github.com/iRayanKhan/homebridge-tuya/wiki/Supported-Device-Types#garage-doors

For my current cloud tuya home assistant setup I use this cover config:

configuration.yaml:

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage Door"
        value_template: >-
          {% if is_state('binary_sensor.ty0053602798f4abba28f3','on') %}
            Open
          {% else %}
            Closed
          {% endif %}
        open_cover:
          service: switch.turn_on
          data:
            entity_id: switch.ty0053602798f4abba28f3
        close_cover:
          service: switch.turn_off
          data:
            entity_id: switch.ty0053602798f4abba28f3
        stop_cover:
          service: switch.turn_on
          data:
            entity_id: switch.ty0053602798f4abba28f3
        icon_template: >-
          {% if is_state('binary_sensor.ty0053602798f4abba28f3','on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}

customize.yaml:

cover.garage_door:
  device_class: garage
myevit commented 2 years ago

Trying to add my garage opener and getting an error "Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect." ID and key are from my currently working homebrigde setup, IP is correct too (would be nice to have autodiscovery though) By the way this is the device I am using https://www.amazon.ca/gp/product/B072SFDKDH?th=1 it's https://www.espressif.com/ device

Logger: custom_components.tuya_local.device
Source: custom_components/tuya_local/device.py:236
Integration: tuya_local (documentation, issues)
First occurred: 08:58:37 (1 occurrences)
Last logged: 08:58:37

Failed to refresh device state for Test.
2021-11-14 09:27:40 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for Test to 3.3.
2021-11-14 09:27:40 DEBUG (SyncWorker_9) [custom_components.tuya_local.device] Refreshing device state for Test.
2021-11-14 09:27:41 DEBUG (SyncWorker_9) [custom_components.tuya_local.device] Retrying after exception 'dps'
2021-11-14 09:27:41 INFO (SyncWorker_9) [custom_components.tuya_local.device] Setting protocol version for Test to 3.1.
2021-11-14 09:27:47 DEBUG (SyncWorker_9) [custom_components.tuya_local.device] Retrying after exception 'dps'
2021-11-14 09:27:47 INFO (SyncWorker_9) [custom_components.tuya_local.device] Setting protocol version for Test to 3.3.
2021-11-14 09:27:48 DEBUG (SyncWorker_9) [custom_components.tuya_local.device] Retrying after exception 'dps'
2021-11-14 09:27:48 INFO (SyncWorker_9) [custom_components.tuya_local.device] Setting protocol version for Test to 3.1.
2021-11-14 09:27:48 DEBUG (SyncWorker_9) [custom_components.tuya_local.device] Retrying after exception 'dps'
2021-11-14 09:27:48 ERROR (SyncWorker_9) [custom_components.tuya_local.device] Failed to refresh device state for Test.
2021-11-14 09:27:48 INFO (SyncWorker_9) [custom_components.tuya_local.device] Setting protocol version for Test to 3.3.
make-all commented 2 years ago

If your homebridge is setup to connect to the same device, and running, it may be blocking the connection. Tuya seems to have limited their devices to a single local connection.

myevit commented 2 years ago

If your homebridge is setup to connect to the same device, and running, it may be blocking the connection. Tuya seems to have limited their devices to a single local connection.

That was it! Homebridge was taking exclusive control over. Once disabled your Tuya integration got connected to the garage opener right away. All working like a charm. Icon, buttons, arrows. Next step for me to try to export device through homekit controller to Apple devices...

Great stuff!!! Thank you!