Cheap Tuya based PIR Battery cameras - how to make them more usable with Home Assistant

I picked up a really dirt cheap Woox PIR battery cameras from Amazon for £18 . These are battery operated and like Blink, only intended to wake up when motion is detected. Figured it was worth a punt as I know their other indoor home cameras are compatible with Tuya .

https://www.amazon.co.uk/Woox-Smart-Outdoor-Camera-Waterproof/dp/B07QD6D3X8

The bummer was that the new Tuya integration was not pulling in the pir_switch or the wireless_awake entity which I could clearly see available in the IoT portal for the device. Additionally the Tuya Smart App did not allow a schedule for making the PIR active. This makes the device pretty unusable with Home Assistant because it would mean you would have to use the Tuya Smartlife App to turn PIR on and off manually when needed, and if using this camera in a high traffic area and only wanting it monitored at certain times, the battery would drain out.

My intended use, was for an indoor area , and only wanted it monitored at night .

I’ve never really looked at HA integration from a coding perspective before, so figured I’d give it ago, and turns out, for this anyway, it was really simple :slight_smile:

/usr/src/homeassistant/homeassistant/components/tuya

const.py

@@ -82,6 +82,7 @@
 DEVICE_CLASS_TUYA_LED_TYPE = "tuya__led_type"
 DEVICE_CLASS_TUYA_LIGHT_MODE = "tuya__light_mode"
 DEVICE_CLASS_TUYA_MOTION_SENSITIVITY = "tuya__motion_sensitivity"
+DEVICE_CLASS_TUYA_PIR_SWITCH = "tuya__pir_switch"
 DEVICE_CLASS_TUYA_RECORD_MODE = "tuya__record_mode"
 DEVICE_CLASS_TUYA_RELAY_STATUS = "tuya__relay_status"
 DEVICE_CLASS_TUYA_STATUS = "tuya__status"
@@ -218,6 +219,7 @@
     MODE = "mode"  # Working mode / Mode
     MOTION_RECORD = "motion_record"
     MOTION_SENSITIVITY = "motion_sensitivity"
+    PIR_SWITCH = "pir_switch" # pir sensitivity
     MOTION_SWITCH = "motion_switch"  # Motion switch
     MOTION_TRACKING = "motion_tracking"
     MUFFLING = "muffling"  # Muffling          

switch.py

@@ -219,7 +218,6 @@
      MODE = "mode"  # Working mode / Mode
      MOTION_RECORD = "motion_record"
      MOTION_SENSITIVITY = "motion_sensitivity"
+    PIR_SWITCH = "pir_switch" # pir sensitivity
      MOTION_SWITCH = "motion_switch"  # Motion switch
      MOTION_TRACKING = "motion_tracking"
      MUFFLING = "muffling"  # Muffling

strings.select.json

@@ -33,6 +33,12 @@
       "1": "Medium sensitivity",
       "2": "High sensitivity"
     },
+      "tuya__pir_switch": {
+      "0": "Off",
+      "1": "Low sensitivity",
+      "2": "Medium sensitivity"
+      "3": "High sensitivity" 
+    },
     "tuya__record_mode": {
       "1": "Record events only",
       "2": "Continuous recording"

In order to make decisions on the PIR being triggered on or off, we can pull in the wireless_awake status entity which will allow us to make decisions in HA :

const.py

@@ -310,6 +313,7 @@
     WATER_SET = "water_set"  # Water level
     WATERSENSOR_STATE = "watersensor_state"
     WET = "wet"  # Humidification
+    WIRELESS_AWAKE = "wireless_awake" # wake wifi switch
     WIRELESS_BATTERYLOCK = "wireless_batterylock"
     WIRELESS_ELECTRICITY = "wireless_electricity"
     WORK_MODE = "work_mode"  # Working mode

switch.py

@ -368,6 +368,12 @@
             name="Motion Alarm",
             entity_category=ENTITY_CATEGORY_CONFIG,
         ),
+        SwitchEntityDescription(                                 
+            key=DPCode.WIRELESS_AWAKE,
+            icon="mdi:eye-off",
+            name="Wireless Awake",     
+            entity_category=ENTITY_CATEGORY_CONFIG,
+        ), 
     ),
     # IoT Switch?
     # Note: Undocumented

Transfotmed a cheap, wireless unusable camera, to something a bit more useful.

EDIT

One small issue I ran into…You can’t modify the PIR setting when the device is not awake, so a bit of a catch 22 in that if you disable PIR, you can only enable it via the Tuya Smartlife app - I can’t see any way to wake these cameras up remotely without that app. I’m monitoring the device battery performance in a high traffic area on low PIR sensitivity.

If battery life is decent, I might get a couple more for backup to my Blink integration.

2 Likes

Just my opinion, but it would be more productive and helpful for the community to have your improvement included in HA via a pull request rather than having a guide that is only useful for the relative small amount of users using the Core install.

Also, be well aware that your changes will be overwritten the next time you upgrade HA.
If you don’t want to do a PR (or it’s refused or ignored for whatever reason), at least duplicate the tuya component as custom_component, so that your changes will survive an upgrade.

I am well aware and have backed up my changes for any future upgrade…have you any pointers on where I would commit these changes to in order to do that?

fyi…I am using Hass.io, not core install, and making my changes to the tuya component through the docker shell.

To do which? A PR or a custom_component?

A pull request…

Ignore…I found it here :

Pull request added :

4 Likes

do we know when this will be rolled out ?

2 Likes

Would love to see this PR to get merged