alexander-vitishchenko / hc3-to-mqtt

Fibaro HC3 integration with Home Assistant & NodeRed
MIT License
31 stars 13 forks source link

Change MQTT Topic #33

Closed MomosX closed 1 year ago

MomosX commented 2 years ago

I have tried to change the MQTT topic to something like HC3/ . Made the change in mqtt_convention_api.lua line 39.

MqttConventionHomeAssistant = inheritFrom(MqttConventionPrototype) MqttConventionHomeAssistant.type = "Home Assistant" MqttConventionHomeAssistant.rootTopic = "HC3/"

Bridge starts but HA does't see any device.

For sure i'm missing something :) Please help.

PS: need to change the topic as i have quite a few Mqtt devices , all flooding homeasisstant topic.

Thank you !

alexander-vitishchenko commented 2 years ago

Home Assistant MQTT Discovery specification requires "homeassistant" root folder to be used by default. See https://www.home-assistant.io/integrations/mqtt for details.

If you want Home Assistant to listen for events in a different root folder - try reading HA manual https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery, but I've never tried doing so.

Can you please advise what is exactly the problem you are trying to resolve? There must be a different and maybe even a better way to get it done.

MomosX commented 2 years ago

Let me try to explain what is happening since first version of the QA.

Sometimes i make modifications to device parameters, delete or add a device in HC3. For some reason from time to time i see all the entities from HC3 in HA as unavailable. I stop the QA and restart it... but .. HA indexes the entities with _2, _3 and so on.
The way i'm solving this now is by opening MQTT Explorer, let it run a bit, then delete all homeassitant topics/messages and restart the QA. Then all is good. But unfortunatelly in the topic homeassistant there are some other entities provided by other integrations. So i have to go restart those integrations again. Deleting only the HC3 entities from MQTT Explorer is a pain as there are many of them.

Maybe there is a way to tell the QA when is starts to clear all messages/topics ?

Usever commented 2 years ago

Sometimes i make modifications to device parameters, delete or add a device in HC3. For some reason from time to time i see all the entities from HC3 in HA as unavailable. I stop the QA and restart it... but .. HA indexes the entities with _2, _3 and so on.

To me it also happens on a simple HC3 reboot, not for the all entities, but some are also getting new indexes _2, _3, second reboot resolves it.

alexander-vitishchenko commented 2 years ago

Can you please share few examples, how you edit Fibaro devices?

I'm pretty sure this is something what I can fix if the problem is on QuickApp side (not how HA MQTT specs designed to work). Just need more details.

And then you no longer need to purge devices via MQTT Explorer that impact other integrations :-)

alexander-vitishchenko commented 1 year ago

Hi @Usever,

Just to keep you updated - there is ongoing discussion about solution design at #35

alexander-vitishchenko commented 1 year ago

Hi @MomosX can you please advise if this issue is a duplicate of #35, and we can close it?

MomosX commented 1 year ago

yup . same issue. can be closed. The only way things will get messed up now is if we exclude/include a device in HC3 or do something that changes the device ID in HC3. Which of course is not something this QA can solve:)

alexander-vitishchenko commented 1 year ago

QuickApp is actually able to get events from Fibaro HC3 about devices added/changed/removed, and keep Home Assistant in sync without restart.

If this request is different than #35, then let's not close it as duplicate, and spend a bit more time to investigate what you initially proposed? Ideally in a form of a few scenarios so I see what you propose and why this would be valuable.

Sorry for not being able to get the idea initially, and Il just trying to help :-)

MomosX commented 1 year ago

Originally i wanted to change the MQTT topic all together, just to be able able to purge HC3 entities when something went wrong and i had misslabled entities. That was the only reason. Now the need to purge the MQTT is gone as it was solved here #35 . The fix is a long term one and for the last 24h i've been trying to "break" it with no success. I even excluded devices from HC3 and reincluded to see what happens. All went good.
From my point of view the reason i opened this request is gone.