tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
869 stars 206 forks source link

Support for doorbell human detection sensors and button press #673

Open felipecrs opened 2 years ago

felipecrs commented 2 years ago

Currently I can already control my doorbell in HA with the Tuya Integration with the following entities:

image

However, two of the most useful sensors are missing: button press and human detection. It's already possible to create automations/scenes inside of the Tuya app based on those events, but they are not exposed to Home Assistant just yet.

https://user-images.githubusercontent.com/29582865/140601203-bce4f90b-1a4b-4cc6-a39a-2fbe7bf21d42.mp4

For example, if button press sensor was integrated with HA, I could ring a bell inside my home (just an example). Specifically, I want to run some ADB commands to turn on my tablet screen and enter on Tuya app so that I can answer the video doorbell call as seamlessly as possible.

Device normal info

Device info:

[
  {
    "code": "basic_indicator",
    "value": true
  },
  {
    "code": "ipc_flip",
    "value": "flip_none"
  },
  {
    "code": "basic_osd",
    "value": true
  },
  {
    "code": "basic_nightvision",
    "value": "0"
  },
  {
    "code": "sd_format",
    "value": false
  },
  {
    "code": "wireless_lowpower",
    "value": 5
  },
  {
    "code": "wireless_awake",
    "value": false
  },
  {
    "code": "pir_switch",
    "value": "0"
  },
  {
    "code": "humanoid_filter",
    "value": false
  }
]

Device specifications: chrome_iIFADxOdXq

felipecrs commented 2 years ago

Related:

https://github.com/tuya/tuya-home-assistant/issues/673 https://github.com/tuya/tuya-home-assistant/issues/353

kooibosmania commented 2 years ago

i second this, i have kruidvat doorbell and can also see video and other entities but not the sensor for the button so the most usefull sensor is not there

naijaping commented 2 years ago

Same issue here aswell, any help will be appreciated

ddkooker2 commented 2 years ago

+1

spectreman51 commented 2 years ago

+1. I try to find another method in order to be informed when the button is pressed.

ddkooker2 commented 2 years ago

+1. I try to find another method in order to be informed when the button is pressed.

Here to i have read somewhere that the devices can be controlled locally using the smart things app, isn't this an option to use for HA, the delays and mis/match of the status is throwing all my automations off and because off that i am starting to look at localtuya/tuyaconvert to just ditch the whole cloud intergration.

cherryocola commented 2 years ago

+1

FragMenthor commented 2 years ago

+1

Czara commented 2 years ago

You can use rf433 to detect button press. I use it! When People press the button I take a photo with cam and this photo appears on my tv and I play sound to my sonos.

cherryocola commented 2 years ago

You can use rf433 to detect button press. I use it! When People press the button I take a photo with cam and this photo appears on my tv and I play sound to my sonos.

Can you elaborate how this is done? thanks!

Czara commented 2 years ago

You can use rf433 to detect button press. I use it! When People press the button I take a photo with cam and this photo appears on my tv and I play sound to my sonos.

Can you elaborate how this is done? thanks!

Hello I use a sonoff rf bridge v2 with direct hack. On this sonoff I installed esphome (https://www.esphome-devices.com/devices/Sonoff-RF-Bridge) and I captured the code when I pushed the doorbell button. This code is write in esphome code, the format used is rcswitch. You can use probably another rfbridge like rf link.

After I used this automation :

alias: Sonnette
description: Notifications multiples lorsque quelqu'un sonne
trigger:
  - type: motion
    platform: device
    device_id: 69b7eaadd8436c4aba9866a24e796dcf
    entity_id: binary_sensor.sonnette
    domain: binary_sensor
condition: []
action:
  - service: media_player.play_media
    data:
      entity_id: media_player.sonos_cloud
      media_content_id: >-
        https://xxxx.ui.nabu.casa/local/sound/Doorbell.mp3
      media_content_type: music
      extra:
        volume: 35
        play_on_bonded: true
  - service: camera.snapshot
    target:
      entity_id:
        - camera.visiophone_wifi
    data:
      filename: /config/www/images/sonnette.jpg
  - service: notify.All_FireTV
    data:
      title: On sonne
      message: Quelqu'un sonne à la porte !
      data:
        duration: 20
        position: bottom-left
        fontsize: medium
        transparency: 80%
        color: teal
        interrupt: 0
        image:
          url: >-
           https//xxxx.ui.nabu.casa/local/images/sonnette.jpg
  - service: notify.all_mobiles
    data:
      message: Quelqu'un sonne à la porte
      title: On sonne !
      data:
        image: /local/images/sonnette.jpg
        data:
          entity_id: camera.visiophone_wifi
        actions:
          - action: URI
            title: Voir les caméras
            uri: /lovelace/camera
            clickAction: /lovelace/camera
mode: single
cherryocola commented 2 years ago

Awesome! Seems like a lot of work but I guess I will give it a try as soon as I have some free time. Thanks!

naijaping commented 2 years ago

You can use rf433 to detect button press. I use it! When People press the button I take a photo with cam and this photo appears on my tv and I play sound to my sonos.

Can you elaborate how this is done? thanks!

Hello I use a sonoff rf bridge v2 with direct hack. On this sonoff I installed esphome (https://www.esphome-devices.com/devices/Sonoff-RF-Bridge) and I captured the code when I pushed the doorbell button. This code is write in esphome code, the format used is rcswitch. You can use probably another rfbridge like rf link.

After I used this automation :

alias: Sonnette
description: Notifications multiples lorsque quelqu'un sonne
trigger:
  - type: motion
    platform: device
    device_id: 69b7eaadd8436c4aba9866a24e796dcf
    entity_id: binary_sensor.sonnette
    domain: binary_sensor
condition: []
action:
  - service: media_player.play_media
    data:
      entity_id: media_player.sonos_cloud
      media_content_id: >-
        https://xxxx.ui.nabu.casa/local/sound/Doorbell.mp3
      media_content_type: music
      extra:
        volume: 35
        play_on_bonded: true
  - service: camera.snapshot
    target:
      entity_id:
        - camera.visiophone_wifi
    data:
      filename: /config/www/images/sonnette.jpg
  - service: notify.All_FireTV
    data:
      title: On sonne
      message: Quelqu'un sonne à la porte !
      data:
        duration: 20
        position: bottom-left
        fontsize: medium
        transparency: 80%
        color: teal
        interrupt: 0
        image:
          url: >-
           https//xxxx.ui.nabu.casa/local/images/sonnette.jpg
  - service: notify.all_mobiles
    data:
      message: Quelqu'un sonne à la porte
      title: On sonne !
      data:
        image: /local/images/sonnette.jpg
        data:
          entity_id: camera.visiophone_wifi
        actions:
          - action: URI
            title: Voir les caméras
            uri: /lovelace/camera
            clickAction: /lovelace/camera
mode: single

Is there anyway to use broadlink rm4 pro to intercept the code instead of sonoff bridge ?

Czara commented 2 years ago

Hi I don't know I don't have rm4. Test it!

Have a good day !

FragMenthor commented 2 years ago

Is there anyway to use broadlink rm4 pro to intercept the code instead of sonoff bridge ?

I have a rm3 pro+ and I could not manage to get any code while in learning mode. But probably can vary on the model...

But the point is that this is STALLE, not even thinking of the camera or sensors, what's the point of having support to doorbells if the doorbell press is not supported???? That's the minimum bare function of a doorbell... Months ago, when there was a "boom" of development with the new integration, was said that correct support for smart doorbells was near and in development. Since that release, basically NOTHING changed in this integration, at least to my knowledge and I keep a very close eye on thinks. Is the whole integration STALLE???

sacredprey005 commented 2 years ago

I second this. hope you can add sensor to detect button press

wolfcam commented 2 years ago

The main problem with not being able to implement this functionality is that Tuya IoT doesn't support the doorbell button state as documented here (SP Device Category) - https://developer.tuya.com/en/docs/iot/s?id=K9gf48qapbl1n

Electronlibre2012 commented 2 years ago

Hello all!

same boat ;) solution :

1-Connect to your account Tuya IOT Platform with your PC, create a virtual switch for light in Tuya IOT (i take the neutral + line zigbee) in "Cloud > Devices > All Devices > button Add Devices" 2-you will have a QR code then go tu your Tuya App on phone, in my home" right corner up click "+" then again right corner up QR code symbol, flash the QR code with your phone on the PC screen, the switch is now link to the App and you have a virtual switch in HA. 3-Still in the App phone, create an automation : when doorbell button is press...then...virtual switch put on...wait 2 seconds...then put virtual switch off...DONE!

in HA, do what you want with the state of the virtual switch...like notify, snaptshot, ....with an automation.

Enjoy

wolfcam commented 2 years ago

Hello all!

same boat ;) solution :

1-Connect to your account Tuya IOT Platform with your PC, create a virtual switch for light in Tuya IOT (i take the neutral + line zigbee) in "Cloud > Devices > All Devices > button Add Devices" 2-you will have a QR code then go tu your Tuya App on phone, in my home" right corner up click "+" then again right corner up QR code symbol, flash the QR code with your phone on the PC screen, the switch is now link to the App and you have a virtual switch in HA. 3-Still in the App phone, create an automation : when doorbell button is press...then...virtual switch put on...wait 2 seconds...then put virtual switch off...DONE!

in HA, do what you want with the state of the virtual switch...like notify, snaptshot, ....with an automation.

Enjoy

Thanks, i wil try this !

felipecrs commented 2 years ago

This is neat, previously I was using a real Tuya switch for that purpose. I didn't know I could create a virtual one. Thank you!

FragMenthor commented 1 year ago

Hello all! same boat ;) solution : 1-Connect to your account Tuya IOT Platform with your PC, create a virtual switch for light in Tuya IOT (i take the neutral + line zigbee) in "Cloud > Devices > All Devices > button Add Devices" 2-you will have a QR code then go tu your Tuya App on phone, in my home" right corner up click "+" then again right corner up QR code symbol, flash the QR code with your phone on the PC screen, the switch is now link to the App and you have a virtual switch in HA. 3-Still in the App phone, create an automation : when doorbell button is press...then...virtual switch put on...wait 2 seconds...then put virtual switch off...DONE! in HA, do what you want with the state of the virtual switch...like notify, snaptshot, ....with an automation. Enjoy

Thanks, i wil try this !

Amazing!!! That seemed like the right solution right away, but I'm stuck with a doorbell that does not have that trigger in SmartLife / Tuya app... Amazingly enough, I can now trigger, with your solution, the motion status by the status os the device (awaken/dormant). The doorbell works "fine" in SmartLife app, triggers a notification to answer, but I have no triggers available to do automations on that... Almost got there....

Electronlibre2012 commented 1 year ago

that's the community power : share your knowledge lol ! :)

ThaDuhFeez commented 1 year ago

Agreed. Having a sensor for button press should be the bare minimum for a smart doorbell.

recklezz commented 1 year ago

Hello all!

same boat ;) solution :

1-Connect to your account Tuya IOT Platform with your PC, create a virtual switch for light in Tuya IOT (i take the neutral + line zigbee) in "Cloud > Devices > All Devices > button Add Devices" 2-you will have a QR code then go tu your Tuya App on phone, in my home" right corner up click "+" then again right corner up QR code symbol, flash the QR code with your phone on the PC screen, the switch is now link to the App and you have a virtual switch in HA. 3-Still in the App phone, create an automation : when doorbell button is press...then...virtual switch put on...wait 2 seconds...then put virtual switch off...DONE!

in HA, do what you want with the state of the virtual switch...like notify, snaptshot, ....with an automation.

Enjoy

This is a great workaround! Can you share which exact virtual light switch you used? I tried many, but the countdown function never works, so the automation cannot turn the switch off.... Any ideas?

EDIT: Figured it out, the countdown function is crap and doesn't work. Just create an automation that turns the switch ON, then add a delay step, then turn switch OFF. I'm using this switch btw : "ZigBee Single Live Light Switch 1 Gang"

Thanks!

felipecrs commented 1 year ago

I faced the same issue as you, but the solution is simple. As soon as you capture the event in Home Assistant, you can turn the switch back to off from Home Assistant as well.

Electronlibre2012 commented 1 year ago

Hello @recklezz

This is a great workaround! Can you share which exact virtual light switch you used? I tried many, but the countdown function never works, so the automation cannot turn the switch off.... Any ideas?

EDIT: Figured it out, the countdown function is crap and doesn't work. Just create an automation that turns the switch ON, then add a delay step, then turn switch OFF. I'm using this switch btw : "ZigBee Single Live Light Switch 1 Gang"

i have choose this one : Device Information Product Name 美标单控开关(zigbee)plus

traduction chinese to english : American standard single control switch(zigbee)plus

this one : https://expo.tuya.com/product/956019

i dont need to turn it off because this switch is a momentary one!

this is my automation :

alias: Video DoorBell
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.virtual_switch_switch_1
    to: "on"
condition: []
action:
  - data:
      gw_mac: 7811dcfb2b35
      ringtone_id: 10
      ringtone_vol: 10
    service: xiaomi_aqara.play_ringtone
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - data:
      gw_mac: 7811dcfb1c9f
      ringtone_id: 10
      ringtone_vol: 10
    service: xiaomi_aqara.play_ringtone
  - data:
      volume_level: 0.3
    entity_id: media_player.maison
    service: media_player.volume_set
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - data:
      entity_id: media_player.maison
      message: Pour information ... , il y a un visiteur au portail
    service: tts.google_translate_say
mode: single

the only thing once create the virtual switch is to be sure you have choose "standard instruction" and not "DP Instruction" : like this :

Sans titre

Select Control Instruction Mode

This configuration will affect the control instruction mode of the specified product under this project. Before you change the mode, refer to the following table of instructions and check the instructions applicable to this product in the two modes respectively.

Table of Instructions

DP Instruction | Standard Instruction -- | -- switch_1
switch_1

works like a charm

tonyperuca commented 1 month ago

My solution for generic Tuya doorbell (without button press sensor) from Aliexpress and integration with Alexa / Home Assistant: 1 - Add doorbell to Tuya app 2 - Sync Tuya with Alexa app (add Tuya skill) 3 - Create a Virtual switch on Tuya IOT platform and add it to Alexa app 4 - In Home Assistant install Tuya integration and refresh it to recognize the virtual switch 5 - Create a scene on Alexa app (when Doorbell pressed = turn ON the virtual switch and to turn off after 5s). After this, your Virtual switch in home assistant will turn on/off automatically when doorbell pressed 6 - In HA create a scritp with browser_mod to pop-up your camera when Virtual switch is turned ON

Scritp for HA using browser_mod: sequence: