#Multiple Z2M sharing MQTT

1 messages · Page 1 of 1 (latest)

crystal swan
#

Having 2 HA instances with separate hardware and there own Z2M setup. (Sep channels)
Can I share the same MQTT broker and push the devices info to the right instance?

When today trying and enable the home assistant update its overwriting and only one instance can be used?

Separate device topic? Or how can this be managed?

#z2m

spark sphinx
#

You can customize the discovery topic for each HA instance, and then point each Z2M instance to its topic

#

Then give each Z2M instance its own topic for bridge/devices

spark sphinx
#

I'm currently using a single broker to handle two Z2M instances talking to a single HA instance, but changing the discovery topic would also allow multiple HA instances

crystal swan
#

Thanks! It seems to work ok but changing the subscription in one of the HA instances did not filter on topic. I still got all devices in both. Still the change on topic seems ok to MQTT server. Named then homeassistant and homeassistant2.

spark sphinx
#

You need to change both and they need to match

crystal swan
#

Yes i did and at least it shows OK in the MQTT brooker.

#

But when adding the subscription on Main HA i added "Homeassistant", on Slave "Homeassistant2". I still get all devices. Becuse when adding the MQTT integration on slave and conencting to local MQTT device i can initially not filter on subscription. I then get them all.

#

Changing the subscription to "Homeassistant2" did not refresh the en devices

#

"MQTT settings" / "Configure MQTT Options"

spark sphinx
#

did you also change that in the Z2M instances?

#

they can be completely separate

#

you can use MQTT explorer to see what's publishing and where

crystal swan
#

Yes according to MQTT explorer im only picking the right devices.

#

29 devices in main and 1 in slave

#

But still 29 shows on both in HA

#

It seems like the devices are not refreshed after changing the subscription

spark sphinx
#

Maybe delete the whole homeassistant topic and everything in it and let it republish

#

Could be stale

crystal swan
#

Becuse if i change the subscription topic to "Homy" the 29 devices are still there... like stuck

#

They should be refreshed right?

#

The problem is that i cant set the subscripe upon adding the integration. Only IP and port. No config.

spark sphinx
#

I would do the following:

  1. Change the publish topic for Z2M instance 1 to z2m-1 and the Z2M HA discovery topic to homey1
  2. Change the publish topic for Z2M instance 2 to z2m-2 and the Z2M HA discovery topic to homey2
  3. Remove the MQTT integration from both HA instances to remove all existing devices
  4. Delete the whole homeassistant topic and subtopics using MQTT Explorer to ensure that nothing is in there
  5. Set up the MQTT integration on both HA instances
  6. Configure each HA MQTT instance to use the right discovery topic in the Configure section
crystal swan
#

Im lost but where to change the Z2M publish topic?

#

And the home assistant integration part in Z2M is that not the same as the discovery topic in the MQTT integration?

spark sphinx
#

if you didn't change Z2M, then that's your problem

#

base_topic:

#

that's why I said that you need to point each Z2M instance to a separate topic

crystal swan
#

ok so base topic is the publish topic? 🙂

spark sphinx
#

yes

crystal swan
#

But what is the difference setting the discovery topic in the z2m HA integration tab vs what is set in the Mqtt integration?

spark sphinx
#

One is writing to it and the other is reading

#

MQTT is a broker between the two

#

Do you understand what MQTT is doing here?

#

Z2M and HA have to agree on where the data is in the broker

crystal swan
#

Sure, i publish the z2m messages over a base topic and then define the messages to the HA to a certain discovery topic. It’s like 2 levels of adress for the same messages.

#

I can then consume the messages in the Mqtt integration but only by discovery topic

spark sphinx
#

Yes

#

And the messages in the discovery topic point to the Z2M base topic

#

You can see all of this in MQTT Explorer

crystal swan
#

What can be a reason that i cant change the settings in Z2M? Trying to submit but nothing. Restarted 3 times now.