Tuya Garage Door Opener with sensors

I had setup it as switch and created additional sensor to track the sensor state.

Switch entity is sending commands to device to initiate the action.

Sensor is tracking magnet value.

localtuya:
  - host: your_device_ip_address
    device_id: your_device_id
    local_key: your_local_key
    friendly_name: Garage Door
    protocol_version: "3.3"
    entities:
      - platform: switch
        friendly_name: Garage Door
        id: 1
        current: 7
        current_consumption: 101
        voltage: 102

sensor:
  - platform: template
    sensors:
      garage_door_is_open:
        unique_id: garage_door_is_open
        friendly_name: Garage Door Is Open
        value_template: "{{ state_attr('switch.garage_door','current_consumption') | float * 10 > 0 }}"

I added localtuya integration twice for one device id and one localkey, but with different entity id’s: 1 for binary sensor and 7 for switch
garage_door_integration
The entities look like

- type: entities
  entities:
    - binary_sensor.garage_door
    - switch.garage_switch

3 Likes

For those with problems geting the tuya localkey heres the easy way!!!

HOW TO - Get All Local Tuya Keys (ALL KEYS, SIMPLE, NO SOLDERING) - YouTube

then i added the switch by the tuya integration and the sensor through the local tuya integration

Can you please show your entity configuration, because I have still problems with the integration?

I’ve never been able to get Local Tuya to work.

The problem with sensors and the Tuya integration is that the Tuya integration doesn’t update the state right away. There’s therefore no point in bringing a Tuya sensor into HA; the delay makes it useless. (I did a test. I set up an automation within the Tuya app, to have the garage door sensor change the state of a Tuya plug, which does integrate as a device in HA. The problem is that the change in state takes some time to be visible in HA.

I have had more success with the Nortek garage door tilt sensors (Z-wave) which work perfectly.

I do have a secondary issue with the Tuya garage door controller, which is that HA treats it as a switch, but in the Tuya app it works as a momentary switch. I’ve tried automations in HA that detect the state change and then toggle the switch; but they don’t work right (door will stop in mid-lift or mid-fall). Going to try the momentary switch integration and see if that helps.

Hi,

I added a switch and a binary sensor like you in the screenshot but the sensor is not the signal from the sensor of the door opener its just a “virtual sensor” or similar, have you figured out a way to set the correct sensor state onto this binary sensor in HA?

Hello,
I have the same problem, I am unable to make the garage door show the status. Now it is no longer possible to use the old version of localtuya. Maybe there is already a way ?? maybe have you quit and are using something else?

Instead of relying on cloud based Tuya integration, go with localtuya, add your garage door device as switch and create a garage door cover using yaml. Please take a look at this: Tuya Garage Door Opener with sensors - #22 by fuatakgun

1 Like

Thanks for reply, I Find Your post before and try do this like You bro but i have a problem. I’m new in home assistant.

localtuya:

  • host: your_device_ip_address
    device_id: your_device_id
    local_key: your_local_key
    friendly_name: Garage Door
    protocol_version: “3.3”
    entities:
    • platform: switch
      friendly_name: Garage Door
      id: 1
      current: 7
      current_consumption: 101
      voltage: 102

This part work for me and i have switch but i have a problem with this part

  • sensor
    garage_door_is_open:
    unique_id: garage_door_is_open
    friendly_name: Garage Door Is Open
    value_template: ‘{{ states.switch.garage_door.attributes.current_consumption | float * 10 > 0 }}’

When i pase it into configuration yaml I’ve got error in line sensor

Maybe i should add something

1 Like

When you click on your switch and access detail view, can you see the attribute as ‘current_consumption’? And does it change based on your magnetic garage door sensor?

Moreover, you can only have one main sensor line and all sensor definitions should go under below it. Either check your formatting in YAML file or check if there is another sensor section.

Update: apparently i had an issue of missing line there, updated it, it should work now.

Thank a lot !! It works !!! :smiley: Is it possilbe to make it like garage door button which show open or close icon depend on sensor status ?

2 Likes

UPDATE: I have gathered everything into one post here

  • Setting up localtuya and sensors in configuration.yaml
localtuya:
  - host: your_device_ip_address
    device_id: your_device_id
    local_key: your_local_key
    friendly_name: Garage Door
    protocol_version: "3.3"
    entities:
      - platform: switch
        friendly_name: Garage Door
        id: 1
        current: 7
        current_consumption: 101
        voltage: 102

sensor:
  - platform: template
    sensors:
      garage_door_is_open:
        unique_id: garage_door_is_open
        friendly_name: Garage Door Is Open
        value_template: "{{ state_attr('switch.garage_door','current_consumption') | float * 10 > 0 }}"
  • setting up cover in configuration.yaml
cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage Door"
        value_template: "{{ states.switch.garage_door.attributes.current_consumption | float * 10 > 0 }}"
        open_cover:
          service: script.garage_door_open
        close_cover:
          service: script.garage_door_close
  • setting up scripts created from UI
alias: garage_door_close
sequence:
  - type: turn_off
    entity_id: switch.garage_door
    domain: switch
mode: single
alias: garage_door_open
sequence:
  - type: turn_on
    entity_id: switch.garage_door
    domain: switch
mode: single
2 Likes

Thank a lot !

sequence:
  - type: turn_on
    device_id: xxx
    entity_id: switch.duza_brama_garazowa
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 700
  - type: turn_off
    device_id: xxx
    entity_id: switch.duza_brama_garazowa
    domain: switch
mode: single
alias: Duża brama garażowa
icon: hass:garage

Something like this ?? I was wondering if the script has to be one that turns off the switch after a while or not

Maybe this is enough

sequence:
  - type: turn_on
    device_id: xxx
    entity_id: switch.duza_brama_garazowa
    domain: switch
mode: single
alias: Duża brama garażowa
icon: hass:garage

updated my previous post

Thanks ! Can I make one script with toggle it should do the same job ?

I would not do like that because you might have issues with out of sync between tuya cloud and local states. So, I wanted to be sure that, it is always doing sth correct and intentional.

Thank you very much for your help, now it works as I always wanted, I think it will be useful not only for me. Thank you for your patience because I am a beginner and I asked a lot of simple questions :smiley: :smiley: :smiley:

Happy to assist through this, enjoy your garage door :slight_smile:

I have never been able to get LocalTuya to work. Mainly because the developer site where you are supposed to get the keys keeps changing, and none of the guides out there has been updated to the latest changes on the developer site, meaning I never get my keys :rofl:

I am using this, it is working so far without any issues. tuyapi/SETUP.md at c0a1526379461d6cc0378d06c6f6a32c90c47208 · codetheweb/tuyapi · GitHub