Tuya motion sensor is not supported in Home Assistant

  • delay: 00:05:00

man you are a BEAST!!

Hi, I’m trying to get this setup so that when motion is detected, Govee LED slight strip turns on. I have a ENER-J motion sensor that is setup with smart life and I have made an automation within the app to send a message when triggered. As mentioned above, this has showed up in my scenes. I have also set up the ping with the IP address of the motion sensor (idk if this is right) as shown by @angadsingh . But it is showing the opposite - connected all the time! so not sure what I am doing wrong. Can anyone help?

binary_sensor:
  - platform: ping
    host: 78.230.4.133
    count: 1
    scan_interval: 1
    name: pir_sensor
  - platform: template
    sensors:
      pir_sensor:
        friendly_name: "Master Bedroom Motion Sensor Alarm"
        value_template: >-
          {{ as_timestamp(states.sensor.date_time.last_changed) - as_timestamp(states.binary_sensor.pir_sensor.last_changed) < states('input_number.motion_sensor_idle_secs')|int }}

Screenshot 2020-12-19 at 7.06.36 PM

Hi, I have found another approach which is less speedy but works for me because of simplicity.
I’m using the presence detection. In other words, has that sensor connected to my router.
Is this sufficient for you?

  • This will detect when “something happens after a while”. Meaning if you open the door, it will flag. If the door stays open and then closes, it will flag. The “delay” between each flag is around 3minutes
  • This is because the sensor connect to the router, then stays idle for about 3 minutes and disconnects. That’s what I am tracking.

Prep and gather info

  • In the Smart Life app, I went to device information (click on device, then “pen” on top right, then device info) - and found the Mac adress. Note that
  • I went to my router to check devices connected. Then opened my door, and watched. I found which one popped up and validated the Mac adress. I noted the IP adress
  • At this point, I “reserved” this ip in my router for this device. It will always stay the same.

Code in configuraiton.yaml

  • The IP I’m tracking in this example is 192.168.86.79 (the second one).
  • I did this this way to have a slower and more tolerant scan for phone presence (hosts: 192.168.86.55-60) and a very tight one for the specific door sensor
  • I’m using the NMAP integration (nothing needed to install) which scans the network for connected IP adresses
device_tracker:
  - platform: nmap_tracker
    hosts: 192.168.86.55-60
    home_interval: 10
  - platform: nmap_tracker
    hosts: 192.168.86.79
    interval_seconds: 1
    consider_home: 1

Code in knowndevices.yaml

  • This is where you will name your entity and link it with the Mac adress you found earlier on
tuya_door_gardenroom:
  icon:
  mac: 48:3f:da:10:f0:80
  name: Door Gardenroom
  picture:
  track: true

There you go

Notes and tests I did

  • The entity created here was device_tracker.tuya_door_gardenroom
  • The entity will have 2 status possible: home and not_home
  • 5 seconds delay on my system between the door opening and status “home”
  • 3m15sec later, the status became “not_home” - regardless if the door stayed open or not.
  • Remember, this is a “something happened” type of sensor - it doesn’t track status
  • It works fine for my need which is to send a small warning on my home assistant when this remote door of my house is opened

Another piece of code…

  • Set manually (override) home or not home (you might need that if you combine automation with lights, or another sensor or whatever. It just seemed to be not much known:
  • You can call a service to set the status manually - note that you don’t call the entity name as usual but the device_id as chosen above:
service: device_tracker.see
data:
  dev_id: tuya_door_gardenroom
  location_name: not_home
1 Like

Thank you so much! You’re a legend!

Hi guys, I was thinking I’d share my Tuya motion sensor workaround. It’s very simple but works great for me. I have a Tomato router (https://www.home-assistant.io/integrations/tomato/). After connecting this integration I get presence status of my LAN devices based on their MAC addresses. I simply found the entity with the MAC address of my motion sensor and created a presence based light automation (home and not_home) for the motion sensor. I tried the above ping based solutions but my console log got flooded with many messages. This one seems a bit cleaner and super easy to use. If you have a supported router you might want to try. :slight_smile:

1 Like

Hey guys,

I also have another work around. Works with Tuya Sensors, Node Red and Alexa Routines, so does rely on the cloud.

First, you will need to link your Alexa to the Tuya / Smart Life skill in the Alexa app.
Then discover devices, so that your Tuya sensor is in the Alexa app.

In Node Red, I downloaded the alexa-local node. https://flows.nodered.org/node/node-red-contrib-alexa-local

I made two of these nodes, and named one SensorOpen and one SensorClosed.
Then I asked Alexa to discover devices, so she found SensorOpen and SensorClosed.

Then I made two routines in the Alexa app;
One to say when my Tuya sensor opens, then turn on SensorOpen.
One to say when my Tuya sensor closes, then turn on SensorClosed.

I played around in Node Red to hook up what lights I wanted to turn on and off, depending on if the sensor was opened or closed, linking the lights to the appropriately named node in node red.

It means that you don’t need a secondary plug in Tuya, because you can set up as many Alexa local nodes with whatever names you want, to match as many Tuya sensors as you have.

Hope this helps someone out!

1 Like

I think you retrieved this information in the Smart Home App. The app just shows your public IP.
Look for the device connected to your WLAN router with the same MAC address as shown in the App for your internal IP.

On the node-red-contrib-alexa-local github repo it says that is not longer working.
Have not tried it yet, but maybe this can be an alternative.

I have installed and am using node-red-contrib-alexa-local without any problems, so it is worth a shot.

I also have node-red-contrib-alexa-home-skill - which requires some more setup, as you have to make new devices at https://alexa-node-red.bm.hardill.me.uk/ which is another account to make at https://alexa-node-red.bm.hardill.me.uk/docs, but I find my alexas find the devices from the contrib-alexa-home-skill a lot quicker than the alexa-local skill.

Did anyone have any luck with the non wifi tuya sensors? Bluetooth or Zigbee?

Thanks Matt!!

I’ve adapted your approach to do the same without the need for the node-red component.

I created an input number for the sensor (0,1)
I created a binary sensor that evaluates the input number
I created two scenes in HA. One to turn the input number to 0 and the other to 1.
I created two routines in Alexa. One to call the 0 scene when the Tuya sensor is open (door sensor example) and one routine to call the 1 scene when the Tuya sensor is closed (door sensor example)

Works a treat.

Now I can use the >90% of cheap tuya sensors on the Australian market. Awesome. Thank you!

2 Likes

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?