LG-WebOS-Remote-Control icon indicating copy to clipboard operation
LG-WebOS-Remote-Control copied to clipboard

Uncaught Error: Failed to execute 'define' on 'CustomElementRegistry' in Home Assistant 2025.3.4

Open KameDomotics opened this issue 8 months ago • 1 comments

I’m encountering a persistent error in Home Assistant 2025.3.4 related to the LG WebOS Remote Control custom card. The error appears multiple times daily in the logs:

Logger: frontend.js.modern.202503060
Source: components/system_log/__init__.py:331
First occurred: 13:00:13 (5 occurrences)
Last logged: 13:35:39

Uncaught error from WebKit 605.1.15 on iOS 18.4.1
Error: Failed to execute 'define' on 'CustomElementRegistry': the name "lg-remote-control-editor" has already been used with this registry
    at /hacsfiles/LG-WebOS-Remote-Control/lg-remote-control.js:30:106
    at t (/hacsfiles/LG-WebOS-Remote-Control/lg-remote-control.js:1:251)
    at module code (/hacsfiles/LG-WebOS-Remote-Control/lg-remote-control.js:272:28)

Steps to Reproduce: 1. Install the LG WebOS Remote Control card via HACS. 2. Add the card to a Lovelace dashboard. 3. Observe the Home Assistant logs for the error. 

Expected Behavior:

The custom element lg-remote-control-editor should be defined only once to prevent the error.

Actual Behavior:

The error indicates that lg-remote-control-editor is being defined multiple times, leading to the Failed to execute 'define' on 'CustomElementRegistry' message.

Environment: • Home Assistant Version: 2025.3.4 • LG WebOS Remote Control Version: Latest via HACS • Browser: Safari on iOS 18.4.1 

Additional Information:

This issue has been previously reported in the community, with users experiencing similar errors when multiple LG TVs are present in the network. 

Suggested Fix:

Implement a check before defining the custom element to ensure it hasn’t been defined already:

if (!customElements.get('lg-remote-control-editor')) {
    customElements.define('lg-remote-control-editor', LgRemoteControlEditor);
}

This approach would prevent the error by ensuring the custom element is only defined once.

KameDomotics avatar Apr 26 '25 12:04 KameDomotics