MQTT auto discovery not working?

Hi,

I am a newbie in home assistant so apologize for my maybe silly questions.

I am trying to add my wyze pan camera in HA through MQTT and auto discovery.
I successfully installed the dafang hack on my camera in order to enable RTSP and mqtt.
I followed this guide to configure it all.
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/blob/master/integration/homeassistant/homeassistant.md

In my configuration.yaml :

mqtt:
  broker: localhost
  discovery: true
  discovery_prefix: homeassistant

in my /system/sdcard/config/mqtt.conf file in my camera :
[root@CamSalon1:config]# cat mqtt.conf

############################################################
# edit this file and move it to /system/sdcard/config/mqtt.conf #
############################################################

export LD_LIBRARY_PATH='/thirdlib:/system/lib:/system/sdcard/lib'

# Options for mosquitto_sub & mosquitto_pub
USER=mqtt_local
PASS=#####
HOST=#####
PORT=1883

# Define a location
LOCATION="Maison"

# Define device name
DEVICE_NAME="CamSalon1"

# 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/dafang/# for testing purposes
TOPIC="$LOCATION/$DEVICE_NAME"

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

# Define additional options for Mosquitto here.
# For example --cafile /system/sdcard/config/DST_Root_CA_X3.pem --tls-version tlsv1
# or use a special id to connect to brokers like azure
MOSQUITTOOPTS="-V mqttv311"

# Add options for mosquitto_pub like -r for retaining messages
MOSQUITTOPUBOPTS=""

# Send a mqtt statusupdate every n seconds
STATUSINTERVAL=30

# Publish and update the light dependant resistor (LDR) status or not. The
# default value if the variable is not set is to send it. This might be useful
# for owners of devices that lack the hardware sensor to avoid publishing
# rubbish.
SENDLDR="true"

The problem is I don’t see any Camera in my HA, no entity, nothing.
Where should I find my “CamSalon1” device in HA ?

If i connect in ssh on my hassio to debug, I can see the topics :

> mosquitto_sub -u mqtt_local -P '######' -h localhost -v -t '#'

homeassistant/binary_sensor/CamSalon1/motion/config {“name”: “CamSalon1 motion sensor”, “unique_id”: “2caa8e0f6831-motion-sensor”, “device”: {“identifiers”: “2caa8e0f6831”, “connections”: [[“mac”, “2c:aa:8e:0f:68:31”]], “manufacturer”: “Xiaomi”, “model”: “Dafang”, “name”: “Xiaomi Dafang”, “sw_version”: “Dafang Hacks”}, “state_topic”: “Maison/CamSalon1/motion”, “device_class”: “motion”}
Maison/CamSalon1/night_mode/auto ON
homeassistant/switch/CamSalon1/motion_detection/config {“name”: “CamSalon1 motion detection”, “unique_id”: “2caa8e0f6831-motion-detection”, “device”: {“identifiers”: “2caa8e0f6831”, “connections”: [[“mac”, “2c:aa:8e:0f:68:31”]], “manufacturer”: “Xiaomi”, “model”: “Dafang”, “name”: “Xiaomi Dafang”, “sw_version”: “Dafang Hacks”}, “icon”: “mdi:run”, “state_topic”: “Maison/CamSalon1/motion/detection”, “command_topic”: “Maison/CamSalon1/motion/detection/set”}
Maison/CamSalon1/motion/detection ON
homeassistant/switch/CamSalon1/motion_send_mail/config {“name”: “CamSalon1 motion send mail”, “unique_id”: “2caa8e0f6831-motion-send-mail”, “device”: {“identifiers”: “2caa8e0f6831”, “connections”: [[“mac”, “2c:aa:8e:0f:68:31”]], “manufacturer”: “Xiaomi”, “model”: “Dafang”, “name”: “Xiaomi Dafang”, “sw_version”: “Dafang Hacks”}, “icon”: “mdi:run”, “state_topic”: “Maison/CamSalon1/motion/send_mail”, “command_topic”: “Maison/CamSalon1/motion/send_mail/set”}
Maison/CamSalon1/motion/send_mail OFF
homeassistant/switch/CamSalon1/motion_send_telegram/config {“name”: “CamSalon1 motion send telegram”, “unique_id”: “2caa8e0f6831-motion-send-telegram”, “device”: {“identifiers”: “2caa8e0f6831”, “connections”: [[“mac”, “2c:aa:8e:0f:68:31”]], “manufacturer”: “Xiaomi”, “model”: “Dafang”, “name”: “Xiaomi Dafang”, “sw_version”: “Dafang Hacks”}, “icon”: “mdi:run”, “state_topic”: “Maison/CamSalon1/motion/send_telegram”, “command_topic”: “Maison/CamSalon1/motion/send_telegram/set”}
Maison/CamSalon1/motion/send_telegram OFF
homeassistant/camera/CamSalon1/motion_snapshot/config {“name”: “CamSalon1 motion snapshot”, “unique_id”: “2caa8e0f6831-motion-snapshot”, “topic”: “Maison/CamSalon1/motion/snapshot”}
Maison/CamSalon1/motion/tracking OFF
homeassistant/switch/CamSalon1/motion_tracking/config {“name”: “CamSalon1 motion tracking”, “unique_id”: “2caa8e0f6831-motion-tracking”, “device”: {“identifiers”: “2caa8e0f6831”, “connections”: [[“mac”, “2c:aa:8e:0f:68:31”]], “manufacturer”: “Xiaomi”, “model”: “Dafang”, “name”: “Xiaomi Dafang”, “sw_version”: “Dafang Hacks”}, “icon”: “mdi:run”, “state_topic”: “Maison/CamSalon1/motion/tracking”, “command_topic”: “Maison/CamSalon1/motion/tracking/set”}
Maison/CamSalon1/motors/vertical 0
homeassistant/switch/CamSalon1/blue_led/config {“name”: “CamSalon1 blue led”, “unique_id”: “2caa8e0f6831-blue-led”, “device”: {“identifiers”: “2caa8e0f6831”, “connections”: [[“mac”, “2c:aa:8e:0f:68:31”]], “manufacturer”: “Xiaomi”, “model”: “Dafang”, “name”: “Xiaomi Dafang”, “sw_version”: “Dafang Hacks”}, “icon”: “mdi:led-on”, “state_topic”: “Maison/CamSalon1/leds/blue”, “command_topic”: “Maison/CamSalon1/leds/blue/set”}
Maison/CamSalon1/motors/horizontal 0

Could you help me please ?

1 Like

I found the problem, I had to delete my mqtt entry in configuration file and had it trought the homeassistant web integration page.

Jutst FYI if you’re having issues with MQTT for control of cameras with the dafang firmware, I’ve an alternative method detailed in my post here: Hacking the XiaomiFang Wifi camera

TLDR: my dafang cams were constantly disconnecting and reconnecting to my MQTT broker which was causing excessive network traffic, high CPU usage, and all sorts of weird issues. So I changed to basic REST commands.

If you’re having trouble with Tasmota devices not being discovered. This one worked for me (posted by KingOS in another thread)

Open the console on the tasmota device and type :

Copy to clipboard

 setoption19 1

this will turn autodiscovery on

1 Like