Tuya motion sensor is not supported in Home Assistant

@angadsingh Thanks for all your help now just trying to iron out the kinks. the sensor isn’t super sensitive by the looks so sometimes it isn’t turning on my light quickly.

Thanks Again

It’s already been said that the answer is no, but as someone who’s worked on the Tuya side of things I just wanted to expand a bit on this.

Home Assistant is a brilliant tool that’s genius lies in it’s ability to work with almost any Python library. This means that HA is just the intermediary, and that all the integrations are actually separate projects from HA. That essentially means that for every integration possible with HA there is a person or persons who have created the relevant code / library / script on their own time and out of their generosity to perform that required integration.

Putting that into perspective a little means realising that literally hundreds of people have created everything that makes HA what it is, and not only do they not get paid for it, they also are effectively anonimous. Not to mention that this is nearly always done through reverse engineering with no manual or help from the people that created the original devices & platforms.

So… YES it is that hard to get more devices in from the Tuya system. It’s a miracle that we have what we do, and for so many different devices & platforms.


Thanks for the in-depth info. As I said, I didn’t mean to sound disrespectful or ungrateful, quite the opposite. The system is amazing and props to everyone who contributes, including yourself. Was more just curing my personal curiosity. Trying to understand the system a bit more.


@angadsingh I’m trying to get my door sensor working the same way but whenever you get the ping it toggles a switch. However, I don’t understand templating and I’m not able that get the template switch working, mind taking a look at it for me?

You’d need to post some code and explain what it does compared to what you want it to do

To be fair if it were possible at present then it would be done regardless of what we’re talking about in relation to HA. So, at best the implication from your comment was that if something wasn’t implemented it’s because everyone was too lazy to do this thing that you needed for your integration needs.

A lot of people far more knowledgeable than myself have spent countless hours getting the tuya integration to where it is. Personally I’m just greatful for their efforts and hope that my own tiny contribution has helped a couple of others.

Unfortunately, as with many platforms tuya is actually a very broad collection of different platforms, firmwares and protocols under one banner. Getting to where we are is amazing. I’m sure there are numerous people privately trying to crack open access to the next set of as yet illusive devices.

You should take a look at the relevant projects and see where you can help. Even debugging /logs can play a huge part in moving things along.

Well basically what @angadsingh did with the motion sensor, which works for the door sensor, I do get the ping.
However when I get the ping I want it to toggle a template switch to on or off instead of turning on a sensor and turning that off after a while.

A template switch seemed like what I want instead of template sensor because of the toggle service a switch has.

I am tried to use this code once this code is added config. yaml my sensor should update as it detects motion? i am having trouble with the last part for the date config part here is my config. what am i missing?


  • platform: ping


    count: 1

    scan_interval: 1

    name: ping_tuya_motion_sensor_Maeleigh_PIR_bathroom

  • platform: template



    friendly_name: "Maeleigh PIR bathroom"
    value_template: >-1
      - platform: time_date


name: Motion Sensor Idle Seconds

initial: 600

min: 10

max: 3600

step: 1

No. This just looks for your sensor every minute but only detects it if the sensor/pir is actually online at that specific moment.

It’s very unreliable, and at best can only tell you that it was triggered at that point in time. So for example this is essentially useless on a read switch / door sensor. But with a pir it’s a bit more useful.

Sadly this is the best solution currently available.

I’ve got this setup so that my PIR / Motion Sensor is being detected every time it’s triggered but I can’t get the template sensor part to switch on. Here’s my code:

- platform: ping
  name: ping_tuya_motion_sensor_intercom
  count: 1
  scan_interval: 1
- platform: template
      friendly_name: "Intercom PIR On"
      value_template: >-
        {{ (as_timestamp(now()) - as_timestamp(states.binary_sensor.ping_tuya_motion_sensor_intercom.last_changed)) < states('input_number.motion_sensor_idle_secs')|int }}
#        {{ as_timestamp(states.sensor.date_time.last_changed) - as_timestamp(states.binary_sensor.ping_tuya_motion_sensor_intercom.last_changed) < states('input_number.motion_sensor_idle_secs')|int }}

    name: Motion Sensor Idle
    min: 60
    max: 600
    step: 30
    icon: 'mdi:motion-sensor'  

Any ideas why the ‘tuya_motion_sensor_intercom’ isn’t being triggered?

So, the solution is to add the following line into the template sensor: entity_id: sensor.time, like so:

- platform: template
      entity_id: sensor.time
      icon_template: 'mdi:motion-sensor'
      friendly_name: "Intercom PIR On"
      value_template: >-
        {{ (as_timestamp(now()) - as_timestamp(states.binary_sensor.ping_tuya_motion_sensor_intercom.last_changed)) < states('input_number.motion_sensor_idle_secs')|int }}

@Phill_Healey template sensors only update when the state of any of the referred entities update. If you see my code, i’ve used the time sensor like this: as_timestamp(states.sensor.date_time.last_changed), whereas you’ve gone ahead and used as_timestamp(now()). That won’t work as now() isn’t an entity where date_time is an entity in my case (of the time sensor). The time sensor is an actual entity which updates state whenever the time ticks!. The hack you’ve put now is well, just a hack. Just use the difference from the time sensor itself instead of now()

@JonnoM what advantage would you get with a template switch over a template sensor? an HA sensor more accurately depicts the behavior of a motion sensor in real life, rather than a switch. The toggle service that you are talking about is used to toggle the switch on or off (and not the other way around- the service isn’t called when the switch toggles!)

once you make the template sensor, you can easily use it in automations to trigger stuff:

condition: state
entity_id: binary_sensor.tuya_motion_sensor_living_room
state: 'off'

@Shannondalebreaux you haven’t given a value template in the template sensor. please check my config

@angadsingh When I used your example it wasn’t updating at all.

Well I don’t know. The time sensor perhaps wasn’t configured correctly?

@angadsingh Yes. Somehow it appears I missed that part.

I’ve actually since removed the secondary sensor and just use the ping part in the trigger of my automation.

Can you post the complete code please?

1 Like

Can you post the completed code?

its here: Tuya motion sensor is not supported in Home Assistant