Tuya motion sensor is not supported in Home Assistant

Thanks [thetastate]
Do you have a link to your setup or would be willing to share. This sounds like a little different approach than I have tried but failed so this might be a good option.
much appreciated,
Km

Would you be able to show how you’ve done this please?

I’m doing this with a door contact sensor, I’ve got the sensor to show in HA by your method of pinging the device, but once it pings the device (to HA) is “disconnected” again. Is there a way of having it so that once the sensor changes state, it sets another value to suggest the door is open? Hoping I’m making sense :smiley:

Dependencies:

  • having linked your Tuya account to Alexa
  • having Alexa integrated to HA

Not all tuya sensors are supported by Alexa. They either won’t have an Alexa/Google link icon or they won’t appear in Alexa. This method only works for Tuya sensors that appear in Alexa after you have linked them.

Two examples follow for a motion and door sensor.

Create the input numbers in configuration.yaml:

input_number:
  door_sensor1_status:
    name: Door Sensor 1 Status
    min: 0
    max: 1
  motion_sensor1_status:
    name: Motion Sensor 1 Status
    min: 0
    max: 1

Create the binary sensors in configuration.yaml:

binary_sensor:
  - platform: template
    sensors:
      door_sensor1:
        friendly_name: "Door Sensor 1"
        unique_id: cst0001
        device_class: door
        value_template: "{{ states('input_number.door_sensor1_status') }}"
     motion_sensor1:
        friendly_name: "Motion Sensor 1"
        unique_id: cst0002
        value_template: "{{ states('input_number.motion_sensor1_status') }}"

Create the scenes in scenes.yaml:

- id: '1619089696416'
  name: DoorSensor1Open
  entities:
    input_number.door_sensor1_status:
      initial:
      editable: false
      min: 0
      max: 1
      step: 1
      mode: slider
      friendly_name: Door Sensor 1 Status
      state: '1'
- id: '1619090201183'
  name: DoorSensor1Closed
  entities:
    input_number.door_sensor1_status:
      initial:
      editable: false
      min: 0
      max: 1
      step: 1
      mode: slider
      friendly_name: Door Sensor 1 Status
      state: '0'
- id: '2619090201185'
  name: MotionSensor1Detected
  entities:
    input_number.motion_sensor1_status:
      initial:
      editable: false
      min: 0
      max: 1
      step: 1
      mode: slider
      friendly_name: Motion Sensor 1 Status
      state: '1'
- id: '2619090201184'
  name: MotionSensor1Clear
  entities:
    input_number.motion_sensor1_status:
      initial:
      editable: false
      min: 0
      max: 1
      step: 1
      mode: slider
      friendly_name: Motion Sensor 1 Status
      state: '0'

Create the routine in Alexa (your routine should call the HA scene):

Create one Alexa routine for each scene in HA.
The Alexa “Add action +” is the name of the HA scene

Thanks minor tweaks and some yaml corrections I have the door switch working.

1 Like

+1 for tuya sensor component!!

Hi everyone

I am sorry I have been trying to understand which one is the more appropriate but I am kind a lost.

I have toilets in the house that are in a no window room. So no matter the time of the day, light is requiered.

So i need the sensor to send the info each time it detects something, to switch on the light. for 30 minutes.

My confirguration.yaml
alias: “sensortoilets”
trigger:
entity_id: sensortoilets
platform: state
to: ‘on’
condition:
condition: time
after: ‘11:00’
before: ‘11:00’
action:

  • device_id: XXX (dont know where to get this one tbh)
    domain: light
    entity_id: toilettes buanderie
    type: turn_on

automation.yaml

Automations.yaml

sensortoilets

  • alias: ‘sensortoilets’
    trigger:
    platform: state
    entity_id: sensortoilets
    condition: []
    action:
    • entity_id: toilettes buanderie
      service: light.turn_on

alias: “sensortoilets”
trigger:
entity_id: sensortoilets
platform: state
to: ‘on’
condition:
condition: time
after: ‘11:00’
before: ‘11:00’
action:

  • device_id: XXX
    domain: light
    entity_id: toilettes buanderie
    type: turn_on

Any idea ?

Another question. I have a big garden and a tiny road to get to the house. As soon as I pass the entrance, I have hidden a detactor, I would like to switch on any light that is consider in the room “garden” on google Home and switch it of after 45 minutes. Any thought ?

Many thanks,

Any idea what to do with a tuya door sensor that not show the local IP ? only show my outside IP address?

you cannot see local IP in tuya app, get mac address of your device from tuya app and login to your router find local address.

crazy did not find it on my router.

There is a catch i didn’t mention earlier :slight_smile: these little bastards are not connected to wifi all the time, depending on your router, you might only see connected devices. If there is an option to see historical connection, you can get it from there. If not, you have to be quick as they stay connected for couple of seconds when they notice a movement and go back offline.

Is there a way to do this but set a variable or persistent state when the binary ping sensor is triggered?

As an example, I have the sensor on my washer door, when opened it triggers to “on” but then goes back to “off” within a couple of seconds (when the sensor goes back to sleep/offline), I would like to persistently have it set to “on” until the binary sensor triggers again (taking the laundry out) so I can set it to “off”.

Any suggestions?

Yes, it is possible, create one boolean input helper, when your ping sensor becomes connected, toggle it like if boolean input is on, make it off otherwise make it on.

On the other hand, i do not think this would be reliable enough if you are done with in a shorter period of time (around 100 seconds). I would suggest you to use a magnetic door sensor.

1 Like

Hi @Dennis_Vogt,
I was searching for a way to make my Tuya door / window detector work with HA and came across this post. Thinking out of the box. I like it :+1:

I have a Jinvoo Power board with 4 power outlets and a USB bank of 4 2.1Amp charging points on it.
This runs on the same Jinvoo app which is basically Tuya.

I bought the Tuya Door sensor thinking it would work but as you know it does not work.
I configured the Door Detector in the Jinvoo App.
I took on board you idea and created two automations in Jinvoo to switch switch 2 of the power board on when open and off when closed.
The actual switch 2 switches straight away when the automation runs in Tuya.
BUT the current Tuya integration wants a 600 second polling time and this is reflected in the state of switch 2. By that I mean the on/off state in HA is delayed by up to 600seconds or 10 minutes depending on what part of the polling cycle the change happens.
I have timed state changes anywhere between 30 seconds to 8 minutes on my tests.
I tried shortening it but got log errors saying it needed min 600s.

Did you have this issue?
If so did you find a way around it?

BTW I did try the service call Tuya: Force_update with no joy.

I could live with it but would like the state change to be more immediate than 600s.

Thank you for your ideas

Instead of using tuya integration, you can setup localtuya integration for your switch and you will get instantaneous updates.

@anon63427907 Thanks for the suggestion.
I have looked at the install from HACS and it looks daunting. watched this YouTube as well as read the doco from HACS.
Did you have any trouble?

Since my day 1 with home assistant, i have been using localtuya, most of devices works flawlessly. I have some battery operated LED light, but that is another story :slight_smile:

While setting up localtuya, 2 main things are needed;

  • finding device key from tuya cli wizard
  • setting up the device in home assistant while picking correct configuration

When yo do it once, you don’t need to do it again.

I believe this will not be the easiest addon to install. Specifically finding the device key and setting. Yes you can hunt down the youtube video and try.

Anyway my suggestion is to try Tuya V2 integrations which supported by TUYA and maybe you have more luck. GitHub - tuya/tuya-home-assistant: Home Assistant custom integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, officially maintained by the Tuya Developer Team.

In my case one of my device have not been supported so then I go with Local TUYA.

Again Local TUYA have a lots of problem, so for newbie not recommended.

Thank you I will look at the Tuya V2. A quick look and it seems much easier for a newbie.

V2 is guarantee the easiest one. Be sure to delete your old TUYA integrations and replace it with V2 is much much better. It get more data too since its used the latest API. The reason why you need to delete the old integrations is just because TUYA cloud usually cant support multiple connections (base on experiences)

TUYA promise to support local in the future but that is still something we can only hope for