flyte / mqtt-io

Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.
MIT License
460 stars 157 forks source link

Separate Devices Running MQTT IO Are Recognized as a Single Device in Home Assistant #344

Open dolai1 opened 5 months ago

dolai1 commented 5 months ago

I appreciate the software; this is letting me pull my remote Raspberry Pi GPIOs into HA cleanly.

I have an issue though. I have two separate instances of MQTT IO running right now on two Raspberry Pis (more to come), but they get merged into a single device in HA (Mosquitto) with all of the entities under it.

I am guessing that I need to change my ha_discovery settings, but not sure how right now.

Each instance has its own MQTT user, it's own topic prefix, and a unique name under mqtt.ha_discovery. The device name is the one that connected most recently and, with MQTT Explorer, I confirmed that the two instances have different unique IDs.

Any idea what I need to change in my configs to get the two to be recognized as separate devices in Home Assistant? Thank you.

dolai1 commented 5 months ago

I think that I figured this out, in case anyone else is running into the same issue: It looks like MQTT IO reports two identifiers when it makes its availability report to HA via MQTT: the device name, and, separately, “mqtt-io”. It looks like HA gets confused with multiple devices reporting the same identifier, even if there are unique IDs that accompany the duplicated one.

So, my workaround involves deleting "mqtt-io", from the “identifiers” line in <python virtual environment location>/lib/python3.11/site-packages/mqtt_io/home_assistant.py

It seems like this could have some unintended consequences, so I’d appreciate the input of anyone with more experience on this. If not, could we change the code to reflect this?