Make sure you’re using the right codes for on and off. On = ‘pir’, off = ‘none’
Thank you. I’m a rookie, can you reveil a little more how to?
After searching and reading, I think this should be put in configuration.yaml , but I’m clueless how to get it to work.
Edit after 2 nights of reading and fiddling:
I’ve put this into the configurarion.yaml, and sensor changes to ON. Still it won’t change back to OFF…
binary_sensor:
- platform: template
sensors:
binary_sensor.sensor_dining:
friendly_name: "Sensor Dining"
value_template: >-
{% if states('binary_sensor.sensor_dining') == 'pir' %}
{{on}}
{% elif states('binary_sensor.sensor_dining') == '' %}
{{off}}
{% else %}
unknown
{% endif %}
Not quite. You have to specify those codes during the config flow for the sensor in localtuya. No yaml required. Make sure you use lower case. Those strings are basically how Tuya decided to specify motion in their Pir sensors. See images.
Thanks, unfortunately I’m using the native Tuya integration
I’ve tried localtuya, but as none of my lights respond, I deleted it (after days of trying)
The native Tuya integration shows the motion sensors without any issues for me. No modifications needed and no additional yaml, it should create a binary sensor for you right out of the box. When I was using it, motion responded within 3 secs or so. Good luck.
Thank you. It responds well, but it never changes back from pir to none…
If only there is a script which virtually pushes the “Set Status” button with this code…
I would get rid of any template sensors you’ve created related to this sensor. If you’re using the sensor using the Tuya integration, you should have a device that creates three entities, a binary sensor, battery and Tamper. See image below. No need for any additional yaml code.
Kia ora, all.
I’ve just bought a Nextech Wifi PIR Motion Sensor which is a Tuya product. However, it’s still showing up as Unsupported within HA. It’s there, but no sensors are showing
I’m running the latest version of HA via Docker… anyone else having this issue?
btw, I’ve found this thread extremely helpful setting up the ping sensor… but now I feel I’m missing out — haha.
Edit: I give up, there’s several similar open issues from over a year ago: PIR WIFI sensor does not changing statuses in HA (motion/no motion) · Issue #144 · tuya/tuya-home-assistant · GitHub
Thanks.
I wish it would work that way, but the sensor keeps at “detected” state (all 4 of them). I can change the state to Off with the manual tool, but not with any script up 'till now.
We have different sensor types though.
What puzzles me, they worked fine with the previous Tuya V2 integration. Also in the Homey app, which uses exact the same API. That app has a setting for the blind time, 60 seconds or more, which sets the status to Off or ‘not detected’ or such.
This is from the diagnostics report:
"last_changed": "2022-07-08T23:19:37.238355+00:00",
"last_updated": "2022-07-08T23:19:37.238355+00:00"
I just set the state to ‘null’ and only then, it updates it’s state after I made it detect me. All sensors see motion several times a day.
"last_changed": "2022-07-10T23:29:44.937671+00:00",
"last_updated": "2022-07-10T23:29:44.937671+00:00"
I also tried the “ping” workaround, but of no avail.
Also in the Homey app, which uses exact the same API. That app has a setting for the blind time, 60 seconds or more, which sets the status to Off or ‘not detected’ or such.
This is exactly what seems to be missing/broken in HA right now, as per the GH issue #144 you linked. I just checked the Tuya debug tools in their web platform and my sensor does send the “detected” alert to them, but there’s no “off” alert. As explained there, this must be defined by the reading app; as you see, Homey seems to do that correctly, but in HA that feature is either forgotten, neglected, or broken. Let’s wait and hope they pick that up and patch it
I have an old S5 acting as a gateway for one of these tuya wifi motion sensors. I have smart life setup for alert notifications. Then I feed last notification to HA through the app.
There is a delay of .5 to 1 sec. I’ve only had it going for a day, but so far it seems mostly reliable.
I also have a doorbell that will not integrate with HA nicely. I have it’s app signed in on the gateway phone as well. Now I can do whatever I want based on app notifications. So this method pretty much makes anything that works via app notifications work with HA.
Is anybody else doing it this way?
Hi everyone,
I have a question regarding this solution now a few years later. I am having the problem of my Tuya sensor staying detected. I tried the given code but it doesn’t work:
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_utc'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
- 'beat'
input_number:
'motion_sensor_idle_secs':
initial: 60
min: 10
max: 360
step: 1
binary_sensor:
- platform: ping
host: 192.168.178.241
count: 1
scan_interval: 1
name: binary_sensor.slimme_pit_sensor
- platform: template
sensors:
tuya_motion_sensor_master_bedroom:
friendly_name: "Sensor Gang"
value_template: >-
{{ as_timestamp(states.sensor.date_time.last_changed) - as_timestamp(states.binary_sensor.binary_sensor.slimme_pit_sensor.last_changed) < states('input_number.motion_sensor_idle_secs')|int }}
Are there any workarounds these days?
Clunky, but having just purchased a few of these, you can use virtual devices and the built in Tuya rules engine to create a work around.
Login to Tuya IoT Platform as you did to setup the integration and go to your cloud project
Find the devices tab, where your Tuya devices should be listed
Select add device, virtual device
Select something i.e a switch or bulb
Choose ‘Add to Tuya App Account’
Scan with the Tuya App
Now you have a virtual device and you can build a simple automation to turn the virtual device on and off with motion. My proof of concept is: IF motion detection status ‘alert’ THEN turn on virtual_bulb, wait 20s, turn off virtual bulb.
The bulb shows up in the standard Tuya integration of Home Assistant and you can go ahead and use it like any other motion sensor.
This isn’t perfect as you’re using Tuya automations in the cloud to drive it, but it is a simple way to get wifi motion sensor functionality working as it should.
I would be very interested in your solution because I also have a lot of devices that work in the app but not via the Tuya integration.
Best wishes
Marc
After the 2023.12 update the ping integration does not detect my motion sensor the way it used to. I even made an automation based on the officail ping documentation but it would not pick up my motion sesnor every time like it used to via yaml code. Anybody got the motion sesnor working right with the new ping integration?
I’m experiencing the same issue; the sensors stopped working after the last update.
Right now I moved to Node-RED and it’s ping feature, it works as it should.
Hello @DominikW
Can you please elaborate on this flow?
I found the ping, but which IP do I use, just the local IP?
And I found the switch, but why is the switch there if I may ask?, and why two outputs combined into one? And how do I add a second output?
I can’t find my tuya PIR though, I think I need the HomeAssistant Sensor here, but I it asks me to create a new sensor, but I just want to select my Tuya PIR?
You see, having a very hard time with NR here.
Many thanks in advance
Peter
The IP is the local IP adress of your motion sensor, I have it at 192.168.0.197 as I set it in my DHCP server. The switch I’m not certin is needed, but for some reason without it I would it would not work as I wanted it to.
The new sensor is a binery sensor with device class motion, if you delete the old integration you can probablly use the same name in the new node-red sensor so you don’t have to change anything in automations of frontend.
Thank you for explaining. But it is not for me, Node Red (not you, don’t get me wrong) is super vague and user-like-me unfriendly
I now use this perfect and easy-peasy workaround: