Dafang Hacked camera MQTT not updating. Any help?

Hi guys,

I have the same problem. Im using Hass.io with the Mosquitto Broker Add-on. I have the Dafang hack working an i can reach and use the RTSP stream.

I edited /system/sdcard/config/mqtt.conf

And put in my information:

# Options for mosquitto_sub & mosquitto_pub
USER=USER1234
PASS=PW1234
HOST=192.168.1.125
PORT=1883

# Define a location
LOCATION="myhome"

# Define device name
DEVICE_NAME="dafang_cam_1"

# Define the base topic used by the camera
# send a message to myhome/dafang/set with the payload help for help.
# Results will be placed in myhome/dafang/${command} or topic/dafang/error - so please subscribe topic/d
TOPIC="$LOCATION/$DEVICE_NAME"

When i look in the Add-on logs i see the following:

1580413963: Client mosqpub|7223-DAFANG_CAM disconnected.
1580413963: New connection from 192.168.1.181 on port 1883.
1580413963: New client connected from 192.168.1.181 as mosqpub|7228-DAFANG_CAM (p1, c1, k60, u'Mosquitto').
1580413963: Client mosqpub|7228-DAFANG_CAM disconnected.
1580413964: New connection from 192.168.1.181 on port 1883.
1580413964: New client connected from 192.168.1.181 as mosqpub|7236-DAFANG_CAM (p1, c1, k60, u'Mosquitto').
1580413964: Client mosqpub|7236-DAFANG_CAM disconnected.
1580413964: New connection from 192.168.1.181 on port 1883.
1580413964: New client connected from 192.168.1.181 as mosqpub|7244-DAFANG_CAM (p1, c1, k60, u'Mosquitto').
1580413964: Client mosqpub|7244-DAFANG_CAM disconnected.
1580413965: New connection from 192.168.1.181 on port 1883.
1580413965: New client connected from 192.168.1.181 as mosqpub|7276-DAFANG_CAM (p1, c1, k60, u'Mosquitto').
1580413965: Client mosqpub|7276-DAFANG_CAM disconnected.

Mosquitto add-on config:

{
  "logins": [
    {
      "username": "USER1234",
      "password": "PW1234"
    }
  ],
  "anonymous": true,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false,
  "quiet_logs": true
}

I got one time discovery of the MQTT entities but now there not updating anymore or reacting to input. I restarted HA and the camera, and tried to stop/start the MQTT services on the camera but no succes.

Any help?

My mqtt.conf file (on the camera) has the following lines:

# Define an autodiscovery prefix, if autodiscovery is desired:
AUTODISCOVERY_PREFIX="homeassistant"

Hey. I am just experiencing the same problem here. Did you found the cause / solutions?

I have this parameter on my mqtt.conf:

AUTODISCOVERY_PREFIX="homeassistant"

In the add-on log I can see the Cam keeps disconnecting

Disconnecting from what?

IIRC the dafang firmware uses mosquitto_pub to send it’s data. That means that whenever data is sent to the broker it will connect, send it’s message and then disconnect. That is not an error.

Sorry, I keep looking and and I find out that this is the expected behavior.

However I am experiencing some troubles controlling the camera via MQTT.
Some times I simply lost the control for a while. Than I was able to control it again.

I was looking for the reason, and i simply assumed that was the disconnecting issue but is not.
any idea?

I am not quite experiment with MQTT as you probably noticed :stuck_out_tongue:

What exactly are trying to control? I found the pan/tilt pretty hopeless.

even simple commands like turn On/Off the the camera LEDs. Sometimes the controls works fine but 80% of the times I cannot control it at all form my home assistant.

Using the camera Web interface I had no problem.