Why use the standard Tuya integration for the switch. Is it possible to configure the switch part in the Garage Opener. When I try I only get presented with the options concerning current. No on/off functions. Or have I missed something
I have been trying to use the same config but for me only the door sensor works, the actual open/closing doesnt work. I have to use the cloud tuya to open close (which doesnt have the door sensor) so its mixed bag at the moment and I was hoping someone could point me in the right direction. Tried all possible combinations of DPs and all versions, still no luck
@fhratul what worked for me is I added a switch then added a binary sensor to that switch like below:
Step 1:
Step 2: add binary sensor to detect door sensor state
step 3: Then i added a button on lovelace to detect garage state and toggle door like so:
type: button
entity: binary_sensor.doorcontact_state
show_state: true
name: Garage Door
tap_action:
action: call-service
service: switch.toggle
service_data:
entity_id: switch.garageswitch
I have the same issue, hopefully my solution works for you too. The way I get around it, is to combine the sensor from LAN with the button from the CLOUD via a “template switch”. This template switch will work as expected.
Here’s my config below:
switch:
- platform: template
switches:
frontgatetemplate:
value_template: '{{ is_state("cover.front_gate_tuya", "open") }}'
turn_on:
- condition: template
value_template: '{{ is_state("cover.front_gate_tuya", "closed") }}'
- service: switch.turn_on
entity_id: switch.bfe76a6cb43a435330xxxx
- delay: "00:00:10"
- condition: template
value_template: '{{ is_state("cover.front_gate_tuya", "closed") }}'
- service: switch.turn_on
entity_id: switch.bfe76a6cb43a435330xxxx
turn_off:
- condition: template
value_template: '{{ is_state("cover.front_gate_tuya", "open") }}'
- service: switch.turn_off
entity_id: switch.bfe76a6cb43a435330xxxx
friendly_name: 'Front Gate'
NOTE: you’ll see that i use conditions to check the sensor just before it executes the action to open or close. I also use a 10 second delay and re-execute the action to open, because sometimes the first request to open does not work.
Anyone else had any luck integrating a garage door? I have just installed one and direct integration with local tuya isn’t working. Might have to try your suggestion
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
The entities look like
- type: entities
entities:
- binary_sensor.garage_door
- switch.garage_switch
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
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
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 !!! Is it possilbe to make it like garage door button which show open or close icon depend on sensor status ?
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
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 ?