MQTT - YiCam - Trying to understand how MQTT works

Hi there :raised_hand_with_fingers_splayed:

I’m using Homeassistant (Hassio in Debian10, core-2021.2.3) since few years now and I’m desperate to understand how MQTT is supposed to be working. :pensive:

I’ve just bought a Yi home 1080 webcam to make some tests, successfully integrated it in homeassistant and using motioneye add-on. I’ve activated MQTT services on the cam but I really don’t understand how to add MQTT entities :-/

I’ve installed mosquitto brocker add-on in hassio, and installed mqtt integration in homeassistant.

My webcam seems to connect successfully to mqtt broker (New client connected from 192.168.1.34 as yi-cam (p2, c1, k120, u’mqtt’).)

My question is, how is “mqtt discovery” supposed to work? Doesn’t that automatically add entities to homeassistant based on MQTT topics?

If not, how I’m supposed to add the webcam sensors to homeassistant?

I’ve read all the docs and I’ve searched on internet for hours without succesfully adding the sensors…

Your device needs to support discovery. Does it?

If you know what the camera is sending, you can create them manually without having to worry about discovery.

Find out what messages are being sent with MQTT Explorer or other app, then configure your sensors and switches accordingly.

My immersion heater is controlled by a Shelly 1PM, and HA communicates via MQTT, all manually configured.

Sensors (not all of them):

- platform: mqtt
  name: "Immersion switch overtemperature"
  state_topic: "shellies/shelly1pm-xxxxxx/overtemperature"
- platform: mqtt
  name: "Immersion switch relay state"
  state_topic: "shellies/shelly1pm-xxxxxx/relay/0"
- platform: mqtt
  name: "Immersion switch switch input"
  state_topic: "shellies/shelly1pm-xxxxxx/input/0"

Switch:

# immersion heater relay
- platform: mqtt
  name: "Immersion switch relay"
  command_topic: "shellies/shelly1pm-xxxxxx/relay/0/command"
  payload_on: "on"
  payload_off: "off"
  state_topic: "shellies/shelly1pm-xxxxxx/relay/0"
  state_on: "on"
  state_off: "off"

Oh gosh, you guys are awesome!

First off, I didn’t know that discovery was something that has to be supported by the device.

But that helped me A LOT, because while searching if the cam supported MQTT discovery I found this that explains how to integrate my YiCam in homeassistant (and also helped me understand the process behind MQTT).

And the other thing that helped me a lot is that I found the MQTT config file in ssh on my Yicam where all the MQTT prefixs, topics, and messages are configured, and this file is way better than the original http page from the webcam to understand how everything works and is supposed to be configured.

Thanks guys, really :heart_eyes:

1 Like