alexander-vitishchenko / hc3-to-mqtt

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

Duplicates in home assistant for same device #55

Closed EzequielPitton78 closed 1 year ago

EzequielPitton78 commented 1 year ago

Describe the bug MQTT Integration in Homeassistant creates duplicate/alternate entity for the same fibaro device:

image

How to reproduce? After remove the integration, clear MQTT and reconfigure and restart quickapp, works, but after some time happens again. Automations in node red stop working because the reference is invalid. Happens in ~60 devices of ~ 350 total devices, seems irrespective of type and controller (below listed)

duplicates.txt

Expected behavior No duplicates

Environment:

image

image

Attach QuickApp logs

Attach Home Assistant logs Attach Home Assistant Core and MQTT integration logs.

home-assistant_2023-07-30T06-57-58.717Z.zip

home-assistant_mqtt_2023-07-30T06-48-20.218Z.zip

alexander-vitishchenko commented 1 year ago

Hi @EzequielPitton78,

I have some thoughts why it may happen in your environment, but need to get full logs from Fibaro, can you please share full logs after the QuickApp restart? (starting from the line "------- HC3 <-> MQTT BRIDGE")

Thank you, Alexander

EzequielPitton78 commented 1 year ago

FIbaro_Log_Complete.txt

Thank you very much!!! Attached!

alexander-vitishchenko commented 1 year ago

Hi @EzequielPitton78,

It looks like the QuickApp works as it should at first glance.

(1) I'd suspect your MQTT might have duplicates caused by the device types change, i.e. the old device retained in the MQTT, while Fibaro firmware or the newer version of the QuickApp broadcasted the same device id but for another device type.

I'd expect this steps to help you, if the assumption above is correct:

  1. Stop the QuickApp
  2. Clear MQTT topics under "homeassistant" (you can use "MQTT Explorer" desktop app)
  3. Start the QuickApp

Please let me know results.

(2) In case it doesn't help - can you please share the additional information from your Home Assistant device list screen, and show all devices (a) by filter <id contains "1604"> and (b) by filter <id contains "1283">?

EzequielPitton78 commented 1 year ago

Instructions followed. Just cleaned all MQTT homeassistant topic, re launched QuickApp. No duplicates now, will check if they appear again and report back.

Devices containing 1604 amd 1283:

image

image

alexander-vitishchenko commented 1 year ago

Great! Please let me know if you still need help, and I'd assume the issue is resolved for now

EzequielPitton78 commented 1 year ago

Hi, unfortunately duplicates appeared again:

image

2023_08_02_duplicates_mqtt.txt

EzequielPitton78 commented 1 year ago

duplicate_comparison.xlsx

The duplicates appeared on different divices. Interesting they are 58 in both days. Will repeat the elimination of MQTT topics and relaunch QuickApp to have more data

rudi70 commented 1 year ago

Hi, unfortunately duplicates appeared again:

image

2023_08_02_duplicates_mqtt.txt

Hi! maybe theer is a topic in your HA (between MQTT-server and HA)? this, you could check in the MQTT-Explorer.... mybe it's not a topic from the Fibaro-side....

in my HA I'm using the Integration of Fibaro AND MQTT and this is the cause to see something double :-)

kr, Rudi

EzequielPitton78 commented 1 year ago

Hi! It thought about it, but I'm just using standard MQTT HA integration, nothing else. I deleted everything again and will keep it under observation to learn more when/where happens. Will report back with the results :)

Ezequiel

EzequielPitton78 commented 1 year ago

Restarted, crashed QuickApp, started again

[02.08.2023] [12:22:55] [DEBUG] [QUICKAPP2285]: ------- Disconnected from Fibaro HC3 [02.08.2023] [12:22:56] [DEBUG] [QUICKAPP2285]: [02.08.2023] [12:22:56] [DEBUG] [QUICKAPP2285]: ------- Disconnected from MQTT/Home Assistant

2023_08_02_Fibaro_Log_Complete.txt

EzequielPitton78 commented 1 year ago

Restarted all HC3 controllers, deleted all MQTT topics, relaunched the QuickApp. Works and no duplicates in HA. Let's see when/if they appear again.

[02.08.2023] [12:38:47] [DEBUG] [QUICKAPP2285]: [02.08.2023] [12:38:47] [DEBUG] [QUICKAPP2285]: ------- Fibaro device configuration and states have been distributed to MQTT/Home Assistant in 12 second(s) [02.08.2023] [12:38:47] [DEBUG] [QUICKAPP2285]: [02.08.2023] [12:38:47] [DEBUG] [QUICKAPP2285]: ------- Connected to Fibaro Home Center 3 events feed [02.08.2023] [12:38:51] [DEBUG] [QUICKAPP2285]: Turn OFF for device #1711 [02.08.2023] [12:38:51] [DEBUG] [QUICKAPP2285]: Turn OFF for device #2163 [02.08.2023] [12:38:51] [DEBUG] [QUICKAPP2285]: Turn OFF for device #2164

image

alexander-vitishchenko commented 1 year ago

Can you please share a full MQTT Info from your Home Assistant? Setting => Devices & Entities => click at "X entities" for MQTT integration => pick two sample duplicates => for each of 2 entities => click at three dots => Device Info => follow screenshots

Step 1

image

Step 2

image
EzequielPitton78 commented 1 year ago

Hello, Interesting finding: affected devices change from one ocurrence to other, but the 3 times deleted and re-run, always appear exactly 57 entities renamed with the "_2" suffix in HA! That's indicative it may not have relation to the devices themselves and more of some numeric limit somewhere instead, right? I say renamed because the original without the suffix desapears from HA.

duplicate_comparison.xlsx

Below the MQTT diagnostic from 2 devices with "_2" suffix. The originals without the suffix are not present anymore.

light.1591_2.txt binary_sensor.1669_2.txt

alexander-vitishchenko commented 1 year ago

One clarification, when you see the entities at Home Assistant for "1591_2" and "1669_2" - are there any entities named as "1591" and "1669", and can you extract MQTT info for them?

EzequielPitton78 commented 1 year ago

Hello! The originals "1591" and "1669" are not in HA anymore. The "1591_2" and the "1669_2" point to the same fibaro device in place of the former. Sorry I should have explained myself better: more than duplicates, appear "renamed"

alexander-vitishchenko commented 1 year ago

Hi @EzequielPitton78, it looks like I need more information for investigation. Luckily we may potentially get it from another report #56.

As I understood - another QuickApp user might be facing a similar situation because of the Home Assistant upgrade to the newer version that seems to be using a newer version of the MQTT spec.

Maybe you can do it faster than another user, and can share Home Assistant MQTT logs with the warning messages that are mentioned at #56?

EzequielPitton78 commented 1 year ago

Hello!

In my case de MQTT warning from HA only shields 1 error and is not from this quickapp: I normally name each fibaro device with the manufacturer/model so no coincidence possible. "Friendly name" of entities appear as a concatenation with new HA MQTT interpretation and is quite ugly. Probably wiill revert back to id number only.

image

Is there any other data extraction that I could make to support your investigation?

Some MQTT entities have an entity name equal to the device name. This is not expected. The entity name is set to null as a work-a-round to avoid a duplicate name. Please inform the maintainer of the software application that supplies the affected entities to fix this issue.

List of affected entities:

update.radar_cocina_interior

LodeBo commented 1 year ago

I have exactly the same problem but in my case it's always with the same devices. As long as i don't login to the Fibaro controller everything is fine but as soon as i login the problems begin. Strange.....

alexander-vitishchenko commented 1 year ago

I could reproduce the issue and working on a fix now

alexander-vitishchenko commented 1 year ago

Ready, you need to do the following:

Please let me know if it works for you?

LodeBo commented 1 year ago

Hi Alexander, Thanks for the update. I installed the new version of the QuickApp today.

Until now it works fine. I will give you an update in a couple of weeks.

Stay save !