Hacking the XiaomiFang Wifi camera

@lolouk44 Sorry if this has been asked somewhere in the thread, I had trouble finding a direct answer.

  1. If I do implement the XiaomiFang hack on my WyzeCam V2s, in the simplest of instructions, how can I integrate it to Home Assistant AND still have the ability to get Motion detection alerts (and have HA react to said alerts)?

  2. Also, would live recording and storage work as expected if I have the SD card in? So, I’d be able to access the motion-triggered x-second clips and continuously recorded hours from the card via HA or my phone?

  3. (This should be an easy answer). Also, I imagine that I could easily create a script in HA to toggle between nightvision & regular to make up for the lack of automatic switching on the XiaomiFang software?

hi @thawizard what do you mean by command under trigger? where do I have to set it up?

Thanks.

  1. If I do implement the XiaomiFang hack on my WyzeCam V2s, in the simplest of instructions, how can I integrate it to Home Assistant AND still have the ability to get Motion detection alerts (and have HA react to said alerts)?
    Easiest is to set up MQTT and use the discovery.

  2. Also, would live recording and storage work as expected if I have the SD card in? So, I’d be able to access the motion-triggered x-second clips and continuously recorded hours from the card via HA or my phone?
    Not sure if this is available from bog standard hacked firmware, I personally use motion for this and save recordings to dropbox

  3. (This should be an easy answer). Also, I imagine that I could easily create a script in HA to toggle between nightvision & regular to make up for the lack of automatic switching on the XiaomiFang software?
    Once point 1. has been completed you’ll have full access to the camera functions

1 Like
  1. I’ve yet to take a look at MQTT, but it’ll be able to react to the motion triggers?
  2. Also haven’t looked into Motion, but how does it work? And How do you cap the number of videos or storage space allowed for the uploaded videos before having the older ones overwritten?
  1. I’ve yet to take a look at MQTT, but it’ll be able to react to the motion triggers?
    Yes

  2. Also haven’t looked into Motion, but how does it work? And How do you cap the number of videos or storage space allowed for the uploaded videos before having the older ones overwritten?
    Motion itself doesn’t manage video storage but I have a script that will delete any video that’s over 7 days:
    find /home/cctv/Dropbox/RPi/motion/ -maxdepth 1 -type f -mtime +7 -exec rm '{}' -f \;

2 Likes

First, I want to say thank you so much for being some forth-coming, helpful, and just generally willing to answer my questions

Last follow-up (until I progress further on my project), how would you modify the script to save videos to a NAS (and so it stores new & deletes older recordings) instead of Dropbox?

Sorry if any other the questions sound silly or newb-ish. I’m very new to the community, but like to get a full understanding of the interactions and workings before I dive deep into my projects. I’ve yet to receive most of my components, so I figured now would be the best time to get thoroughly antiquated with them and the functionality that I want to implement with them.

I use the motion application to detect motion on a video feed and record the video feed (I know it can be a bit confusion). in motion, there is a setting to tell is where to save the videos.
If you prefer, you can use ZoneMinder which does pretty much the same thing.
Once you’ve decided where to save the videos, you can adjust the script to point at the same location

can anyone help me, what is the username and password on Xiaofang hack?

as documented on their wiki it is root/ismart12

1 Like

Need help. Where should I add this code- as a switch, sensor or script? Also Dafang Living Room Left Right gives and error and is requiring a state topic. should be it be state_topic: “LivingRoom/DaFang/status”

Also

  • platform: mqtt
    name: “Dafang Kitchen Down”
    state_topic: “Kitchen/DaFang/status”
    command_topic: “Kitchen/DaFang/set”
    payload_on: “motor_down”
    optimistic: false
  • platform: mqtt
    name: “Dafang Living Room Left Right”
    command_topic: “LivingRoom/DaFang/set”
    payload_off: “motor_left”
    payload_on: “motor_right”
    optimistic: false

I’ve set them as switches
You code (which you really should format using that blue bar on top) does not have a state_topic for Living Room.
Check the Kitchen code and you’ll see the missing line

I made a small app that subscribes to motion topics of the camera via MQTT and detects objects in the snapshot. Detected objects are then published via MQTT. Object detection is based on Yolo network (darkflow implementation).

Will upload the stuff on GitHub, in case anyone is interested.

Lars

1 Like

can someone help me …,
why is my control panel display like that and how do I see the camera outside the local server?

That doesn’t look like a home assistant screen. I assume it is the camera’s web page. So ask on the GitHub site.

1 Like

Well this does not work for me. So I played around and found the file were mqtt topics and commands available. It is in \firmware_mod\scripts folder and file is mqtt-autodiscovery.sh. Just a text editor and open the file and you will see command topics and state topics for each item.

The code that work for me (I want to add seperate key for each movement) is given below. I have included these as swtiches.yaml and add these to group.yaml to get to the frontend

Note: “dafang2” is the DEVICE_NAME and “myhome” is the LOCATION I defines in config/mqtt.conf

  • platform: mqtt
    name: “Dafang2_Right”
    state_topic: “myhome/dafang2/motors/horizontal”
    command_topic: “myhome/dafang2/motors/horizontal/set”
    payload_on: “right”
    optimistic: false

  • platform: mqtt
    name: “Dafang2_Left”
    state_topic: “myhome/dafang2/motors/horizontal”
    command_topic: “myhome/dafang2/motors/horizontal/set”
    payload_on: “left”
    optimistic: false

  • platform: mqtt
    name: “Dafang2_Down”
    state_topic: “myhome/dafang2/motors/vertical”
    command_topic: “myhome/dafang2/motors/vertical/set”
    payload_on: “down”
    optimistic: false

  • platform: mqtt
    name: “Dafang2_Up”
    state_topic: “myhome/dafang2/motors/vertical”
    command_topic: “myhome/dafang2/motors/vertical/set”
    payload_on: “up”
    optimistic: falsePreformatted text

Your code is not formatted correctly. Please see the top of the page.

my config given above work. What I said is what @lolouk44 provided does not work for me. I written here the solution that work for me so that if someone need it they could use it. Not sure why a bullet point replace - . It should be “-”

What @nickrout is saying is that you should use the blue bar at the very top of this page to understand how to format your code so that instead of

  • platform: mqtt

it displays properly formatted as

platform: mqtt

This is because if someone tries to copy your code, they’ll have config errors because " is different than "

1 Like

Sorry for a very basic question, but Ihave a couple of Dafang Camera I would like to integrate into HA.
I can see two hacks in this thread. One by EliasKotlyar and the samtap hack, which is first mentioned i this thread. Which one i recommened?

if it’s a dafang you need the one by Elias.