Tuya Garage Door Opener with sensors

Thanks for the response.

I did set up a switch as you instructed but I’m not getting the script done.

In scripts.yaml file, I’m doing the following as per the tutorial.

alias: garage_door_close
sequence:
  - type: turn_off
    entity_id: switch.garage_door
    domain: switch

  - type: turn_on
    entity_id: switch.garage_door
    domain: switch
mode: single
alias: garage_door_open

It is showing me error at “alias: garage_door_open”.

Can you please help?

Hey there, there are 2 different scripts, not one.

Please double read the main post and try to create 2 different scripts as garage_door_close and garage_door_open

It doesn’t seem to work.

I’m using Tuya official HA integration. Not localtuya. Is that a possible issue?

Ah yes, my solution is about localtuya, i am not a fan of official Tuya integration, still using old version of it :slight_smile:

Your a fucking legend @danioj

Thanks a lot for the explanation and debug logic you applied. i was able to do the same for my device, got it working, felt like a genius.

Thanks !

Hi Dhaval, looks like you’ve gotten some info already but here’s a clearer run down of my setup. This is only for localtuya, I don’t use Tuya cloud integration at all so not sure how would configure it for that.

By the way, in the latest localtuya (v3.3.0 at time of writing) device class can now be set when configuring the entity so no need to customise in HA.

To open and close I add an entity with switch type.
localtuya_1

Next step, configure the entity as below (I’m using DP1 to open/close which is ID 1), give it a name and ignore the other 3 fields. (The ID may vary between different controllers but is likely to be the first one and should be true/false value)

Next add another entity of binary_sensor platform which we’ll use to detect door open/closed

localtuya_4

Configure the entity as below, I’m using 101 but again may vary. It should have a true/false value.
You can now change the device class in localtuya as I mentioned so set this entity to garage_door and it will display properly in HA

Once that’s all done, you should have all the entities you need to use in the cover template I’m using above.

Hope this helps.

Hi There @bamzero I have a Tuya Garage Door opener and I have set it up with Tuya Local. I have followed your instructions above and I cant get the switch to work. I have 4 IDs to choose from and have tried all of them. The only one that seems to get any response is IDs 105.

However, when I select the switch the garage door wont open but I get a notification from the Tuya Smart Life App “Your garage door has been opened for 10 minutes” but the garage door doesn’t actually open? Can anyone help with this setup?

Yeh yours is completely different to mine so I’m not sure how much help I can be, but at a guess I’d say 105 is your open/close sensor (like I used as a binary_sensor above). If HA is flipping it as a switch, it could explain why Smart Life is warning you the door is open.

If you can, try tuyadebug and manually open and close your door so you can see what values you get back during the operation. Just remember to exit Smart Life app completely as keeping it open will usually block localtuya.

I would have thought the first ID would be most likely to trigger the opener but it seems each model varies quite a bit.

Thank @bamzero, I appreciate the prompt reply and help. Im a little embarrassed to ask but should I install the tuyadebug on my home assistant install or on any device that can connect to the same network?

Anything on the network will do the job.

Hi all,

Is there a more recent guide to getting a tuya garage door system running? I’ve got localtuya working (along with the associated api.tuya login)

I can add the garage door opener and add ‘switches’ but all they seem to do is turn the plug on and off, they don’t actually toggle the door opening.

I note that most of the above seems to be outdated as the latest version of localtuya states that configuration via yaml files is no longer supported.

The device I’m using is connected and working fine via the smartlife app and is registered on the tuya api site.

Connect Smart Garage Door Opener - Connect SmartHome

Have been working on this for two days to no avail. Any ideas ?

Thanks

Pete M

Actually I think that the issue may be bigger than Home Assistant. When I log into Tuya and check debugging for the device, I get:

Device Information

Product Name Smart Wireless Garage Door Opener

Device ID 2207********207

Product Category ckmkzq

Device Status Online

Activated At 2022-08-15 13:45:20

But the instruction set is empty

When I go to API explorer and check for the instruction set, I get this:

{
  "result": {
    "category": "ckmkzq",
    "functions": []
  },
  "success": true,
  "t": 16606*******32,
  "tid": "a5********************23f65"
}

However the instruction set for the category “garage door” should be producing this:

{
  "result": {
    "category": "ckmkzq",
    "functions": [
      {
        "code": "countdown_alarm",
        "desc": "countdown alarm",
        "name": "countdown alarm",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "tr_timecon",
        "desc": "tr timecon",
        "name": "tr timecon",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":10,\"max\":120,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_1",
        "desc": "countdown 1",
        "name": "countdown 1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "switch_1",
        "desc": "switch 1",
        "name": "switch 1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_alarm_sound",
        "desc": "switch alarm sound",
        "name": "switch alarm sound",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_3",
        "desc": "switch 3",
        "name": "switch 3",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "door_control_3",
        "desc": "door control 3",
        "name": "door control 3",
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"close\"]}"
      },
      {
        "code": "switch_alarm_1",
        "desc": "switch alarm 1",
        "name": "switch alarm 1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "door_state_1",
        "desc": "door state 1",
        "name": "door state 1",
        "type": "Enum",
        "values": "{\"range\":[\"unclosed_time\",\"close_time_alarm\",\"none\"]}"
      },
      {
        "code": "voice_control_3",
        "desc": "voice control 3",
        "name": "voice control 3",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "door_time_1",
        "desc": "door time 1",
        "name": "door time 1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":10,\"max\":120,\"scale\":0,\"step\":1}"
      },
      {
        "code": "switch_2",
        "desc": "switch 2",
        "name": "switch 2",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "door_time_2",
        "desc": "door time 2",
        "name": "door time 2",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":5,\"max\":300,\"scale\":0,\"step\":1}"
      },
      {
        "code": "door_time_3",
        "desc": "door time 3",
        "name": "door time 3",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":5,\"max\":300,\"scale\":0,\"step\":1}"
      },
      {
        "code": "voice_control_2",
        "desc": "voice control 2",
        "name": "voice control 2",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "voice_control_1",
        "desc": "voice control 1",
        "name": "voice control 1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "alarm_countdown_1",
        "desc": "alarm countdown 1",
        "name": "alarm countdown 1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "alarm_countdown_2",
        "desc": "alarm countdown 2",
        "name": "alarm countdown 2",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "alarm_countdown_3",
        "desc": "alarm countdown 3",
        "name": "alarm countdown 3",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_2",
        "desc": "countdown 2",
        "name": "countdown 2",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_3",
        "desc": "countdown 3",
        "name": "countdown 3",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "door_control_2",
        "desc": "door control 2",
        "name": "door control 2",
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"close\"]}"
      },
      {
        "code": "door_control_1",
        "desc": "door control 1",
        "name": "door control 1",
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"close\"]}"
      }
    ]
  },
  "success": true,
  "t": 16606*******32,
  "tid": "a5********************23f65"
}

But the opener is working fine via the Smartlife Android App, which is making me quite confused.

All my other tuya devices are correctly showing information under API explorer and device debug.

Any ideas ?

Pete

Tuya garage door opener is basically a switch and a contact sensor.

Switch is intitiating an action garage door;

  • if it is already stopped and last activity is opening, start closing
  • if it is already stopped and last activity is closing, start opening
  • if it is already opening or closing, stop it.

I’ve managed to get the 'door state working. I set it up with protocol 3.3 and set id DP102 as ‘binary sensor’ -

On Value= Opened
Off Value= Closed
Device Class= door

Still no good setting up the ‘switch’ and actually activating the open / close sequence.

In the meantime I’ve added a Sonoff PSF-B01 relay in parallel which I’m using via HA to achieve the same thing.

I’d be much happier doing both of the above (switch and state) off the one device so I’m open to suggestions.

Pete

How about the one I suggested earlier on #50? It comes with ESPHome, and (while you still could) you don’t have to flash any firmware to get started.

Problem solved.

Door state solution is as of my earlier post where I setup the binary sensor.

To activate the open / close function, I had to set up the device as a cover, not as a switch. All done via GUI, no yaml configuration.

Thanks for the input.

Pete

You should buy door contact sensor. Your current device is just a relay, cant see if the door is open or not because it just toggles

hi Pete

how did you added it to GUI ?
thanks !

Hi! Would it be possible to set this template as a lock instead of a cover? :slight_smile: I tried but it does not work.

lock:
  - platform: template
    name: Garage door
    value_template: >-
     {% if is_state('binary_sensor.garage_door_status','on') %}
       Open
     {% else %}
       Closed
     {% endif %}
    lock:
      service: switch.turn_on
      target:
        entity_id: switch.garage_door
    unlock:
      service: switch.turn_off
      target:
        entity_id: switch.garage_door
    icon_template: >-
      {% if is_state('binary_sensor.garage_door_status','on') %}
         mdi:garage-open
      {% else %}
         mdi:garage
      {% endif %}

Instead of Open/Close, use on/off.