core icon indicating copy to clipboard operation
core copied to clipboard

ONVIF creates duplicate items

Open jondycz opened this issue 2 years ago • 7 comments

The problem

This usually happens when the cameras or HA is restarted. Last time it happened was last night when a power outage hit. After cameras and HA booted, the old "device" was flagged as unavailable and a duplicate was created. The devices share the same details when viewed from HA hashboard. Have the same MAC address and the same IP address (IP is static)

It seems like the ONVIF integration discovers the device a second time and disables the "old" one. This had happened for like 8th time and only "fix" i found was removing the device entirely from HA and then discovering again so that I didn't have to rewrite the ID in like 10 locations in my Lovelace YAML cards.

This guy has the same issue as I do: https://community.home-assistant.io/t/onvif-every-few-days-adds-duplicate-device/264111

What version of Home Assistant Core has the issue?

core-2022.2.9

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Onvif

Link to integration documentation on our website

https://www.home-assistant.io/integrations/onvif/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

jondycz avatar Apr 08 '22 09:04 jondycz

onvif documentation onvif source (message by IssueLinks)

Hey there @hunterjm, mind taking a look at this issue as it has been labeled with an integration (onvif) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Hi @hunterjm. I found a few forum posts for this and have been struggling with the same problem.

After some troubleshooting, I found that the device stored in core.device_registry contains the wrong MAC address under connections-mac and identifiers-onvif . In my case the IP cameras are on a different VLAN to HA so the MAC address on the wire is my router. This MAC address is not related to the device and should not be referenced.

The good news is that under integrations, the display name shows the correct device MAC address (e.g. Dahua - <correct MAC>). So if you change both references in core.device_registry to use the same MAC as the display name, it should be consistent and not create new devices.

See multiple entries showing incorrect MAC from my core.device_registry:

        {
            "config_entries": [
                "5cb3c1336dcc475030c673c2a4f61dc7"
            ],
            "connections": [
                [
                    "mac",
                    "36:9c:c2:04:2f:a4"
                ]
            ],
            "identifiers": [
                [
                    "onvif",
                    "36:9c:c2:04:2f:a4"
                ]
            ],
            "manufacturer": "Dahua",
            "model": "NVR",
            "name": "Dahua NVR",
            "sw_version": "4.002.0000000.2.R, Build Date 2022-01-20",
            "hw_version": null,
            "entry_type": null,
            "id": "a33574d0d937398a1563160f5a1f1cda",
            "via_device_id": null,
            "area_id": "null",
            "name_by_user": null,
            "disabled_by": null,
            "configuration_url": "http://192.168.101.10:80"
        },
        {
            "config_entries": [
                "5cb3c1336dcc475030c673c2a4f61dc7"
            ],
            "connections": [
                [
                    "mac",
                    "12:97:16:19:09:96"
                ]
            ],
            "identifiers": [
                [
                    "onvif",
                    "12:97:16:19:09:96"
                ]
            ],
            "manufacturer": "Dahua",
            "model": "NVR",
            "name": "Dahua NVR",
            "sw_version": "4.002.0000000.2.R, Build Date 2022-01-20",
            "hw_version": null,
            "entry_type": null,
            "id": "541f40fce0963f63385f9818626df038",
            "via_device_id": null,
            "area_id": null,
            "name_by_user": null,
            "disabled_by": null,
            "configuration_url": "http://192.168.101.10:80"
        },

Thanks, Elton.

earto avatar Apr 20 '22 01:04 earto

Hi @hunterjm ,

Have you had a chance to check my findings above? I suspect this issue could be fixed by using the REAL mac address (as used in the display name) under "connections" and "identifiers".

Every few days my camera entities all fail which is very frustrating. When it happens I have to:

  1. Delete both the original and duplicate NVR devices.
  2. Add the ONVIF device again from scratch.
  3. Delete all failed entities from dashboards and add the new entities.

Here is the duplicate device (Dahua NVR in my case): image

When the 36 entities are duplicated, they all fail. image

If you need any more details, please let me know. Thanks, Elton.

earto avatar May 09 '22 06:05 earto

Hi @jondycz. Did you find another solution or an alternative integration without this bug? Deleting and re-creating all my entities when it randomly creates a duplicate device is driving me crazy. Do you see the same issue in core.device_registry?

Thanks, Elton.

earto avatar May 09 '22 06:05 earto

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 07 '22 07:08 github-actions[bot]

i'm interested in the solution of this problem

ToXinE avatar Aug 09 '22 16:08 ToXinE

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.