MQTT Xiaomi Dafang Camera Hack

Tags: #<Tag:0x00007f2fc2f00b60>

Hi,

I need your help with a switch item and mqtt. I have a Xiaomi Dafang Camera and installed following hack:

I want use mqtt for the settings, but my switch item does not work.

Switch GF_Camera1_Motion “Camera1 Motion” (EnergyValues) {mqtt=">[mosquitto:GF_FF/Camera1/motion/detection:command:*:default], >[mosquitto:GF_FF/Camera1/motion/detection:state:default]"}

MQTT Lens shows:

The log shows:

Thank you in advance!

Désirée

Switch GF_Camera1_Motion “Camera1 Motion” (EnergyValues) {mqtt=">[mosquitto:GF_FF/Camera1/motion/detection:command:*:default], >[mosquitto:GF_FF/Camera1/motion/detection:state:default]"}

The MQTT binding information uses “>” twice. Try changing the second “>” to “<”.

Switch GF_Camera1_Motion “Camera1 Motion” (EnergyValues) {mqtt=">[mosquitto:GF_FF/Camera1/motion/detection:command:*:default], <[mosquitto:GF_FF/Camera1/motion/detection:state:default]"}

A question for you, what kind of motion detector is this that accepts commands? In other words, when you send it “ON”, what does it do with that command?

Would a Contact Item correctly represent the Dafang’s motion detector?

Hi Taras,

thank you very much for your tip. I will try tonight it (also as a contact item). In the dafang hack you have several settings like motion detedtion, led, night vision. I want set the settings via mqtt. Motion detection should be switched off when I am at home.

Kind regards

Désirée

Here are my items:

Switch CAM01_LEDS_BLUE "cam01 leds/blue [%s]" {mqtt=">[broker:cams/cam01/leds/blue/set:command:*:default], <[broker:cams/cam01/leds/blue:state:default]"}
Switch CAM01_LEDS_YELLOW "cam01 leds/yellow [%s]" {mqtt=">[broker:cams/cam01/leds/yellow/set:command:*:default], <[broker:cams/cam01/leds/yellow:state:default]"}
Switch CAM01_LEDS_IR "cam01 leds/ir [%s]" {mqtt=">[broker:cams/cam01/leds/ir/set:command:*:default], <[broker:cams/cam01/leds/ir:state:default]"}
Switch CAM01_IR_CUT "cam01 ir_cut [%s]" {mqtt=">[broker:cams/cam01/ir_cut/set:command:*:default], <[broker:cams/cam01/ir_cut:state:default]"}
Number CAM01_BRIGHTNESS "cam01 brightness [%s]" {mqtt="<[broker:cams/cam01/brightness:state:default]"}
Switch CAM01_RTSP_H264_SERVER "cam01 rtsp_h264_server [%s]" {mqtt=">[broker:cams/cam01/rtsp_h264_server/set:command:*:default], <[broker:cams/cam01/rtsp_h264_server:state:default]"}
Switch CAM01_RTSP_MJPEG_SERVER "cam01 rtsp_mjpeg_server [%s]" {mqtt=">[broker:cams/cam01/rtsp_mjpeg_server/set:command:*:default], <[broker:cams/cam01/rtsp_mjpeg_server:state:default]"}
Switch CAM01_NIGHT_MODE "cam01 night_mode [%s]" {mqtt=">[broker:cams/cam01/night_mode/set:command:*:default], <[broker:cams/cam01/night_mode:state:default]"}
Switch CAM01_NIGHT_MODE_AUTO "cam01 night_mode/auto [%s]" {mqtt=">[broker:cams/cam01/night_mode/auto/set:command:*:default], <[broker:cams/cam01/night_mode/auto:state:default]"}
Switch CAM01_MOTION_DETECTION "cam01 motion/detection [%s]" {mqtt=">[broker:cams/cam01/motion/detection/set:command:*:default], <[broker:cams/cam01/motion/detection:state:default]"}
Switch CAM01_MOTION_SEND_MAIL "cam01 motion/send_mail [%s]" {mqtt=">[broker:cams/cam01/motion/send_mail/set:command:*:default], <[broker:cams/cam01/motion/send_mail:state:default]"}
Switch CAM01_MOTION_TRACKING "cam01 motion/tracking [%s]" {mqtt=">[broker:cams/cam01/motion/tracking/set:command:*:default], <[broker:cams/cam01/motion/tracking:state:default]"}

String CAM01_VERTICAL "cam01 vertical"  {mqtt=">[broker:cams/cam01/motors/vertical/set:command:*:default]"}
String CAM01_HORIZONTAL "cam01 horizonzal"  {mqtt=">[broker:cams/cam01/motors/horizontal/set:command:*:default]"}
Switch CAM01_ACTION "cam01 action" {mqtt=">[broker:cams/cam01/set:command:*:default]"}
sitemap test label="test" 
{
	Frame label="test" 
	{  
        Switch item=CAM01_LEDS_BLUE
        Switch item=CAM01_LEDS_YELLOW
        Switch item=CAM01_LEDS_IR
        Switch item=CAM01_IR_CUT
        Text item=CAM01_BRIGHTNESS
        Switch item=CAM01_RTSP_H264_SERVER
        Switch item=CAM01_RTSP_MJPEG_SERVER
        Switch item=CAM01_NIGHT_MODE
        Switch item=CAM01_NIGHT_MODE_AUTO
        Switch item=CAM01_MOTION_DETECTION
        Switch item=CAM01_MOTION_SEND_MAIL
        Switch item=CAM01_MOTION_TRACKING

        Switch item=CAM01_HORIZONTAL mappings=["left"="links","right"="rechts"]
        Switch item=CAM01_VERTICAL mappings=["up"="hoch","down"="runter"]

        Switch item=CAM01_ACTION mappings=["reboot"="Reboot"]   

        //Video url="rtsp://10.10.10.25:8554/unicast"  encoding="mjpeg"
    }

}

I did not manage to get the video running. Did you?

Thank you very much

Is this camera still recommended in 2019?

That depends on the features that you wish to have without needing an extra server to process the video for motion detection. In most cases it is only $30-60 more for a camera that can do a whole lot more. See this post…

If you can DIY then these esp32 based cameras are cheap and appear to have ready made firmwares to flash to it as well as example source code built into the Arduino IDE.