lock_code_manager icon indicating copy to clipboard operation
lock_code_manager copied to clipboard

[ISSUE] TypeError: e.pinActiveEntity is undefined

Open mousedownmike opened this issue 1 year ago • 4 comments

What happened?

After creating an integration called "Main Doors", I attempted to create a dashboard using the following yaml. I get the error

Error loading the view strategy: TypeError: e.pinActiveEntity is undefined

views:
  - strategy:
      type: custom:lock-code-manager
      config_entry_title: Main Doors
      include_code_slot_sensors: false
    icon: mdi:lock-smart
    title: Lock Code Manager

Steps to reproduce the issue

  1. Create a new Lock Code Entry called "Main Doors"
  2. Use the YAML from above description to create a dashboard.
  3. Observe the TypeError

Home Assistant Version

2024.7.2

What version of Lock Code Manager are you running?

0.5.1

Lock make and model

Schlage FE599

Relevant log output

2024-07-10 17:02:50.263 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'lock_code_manager' calls async_forward_entry_setup for integration, lock_code_manager with title: Main Doors and entry_id: 01J2FDP64980BQ1J8WXBVWF8EG, which is deprecated and will stop working in Home Assistant 2025.6, await async_forward_entry_setups instead at custom_components/lock_code_manager/__init__.py, line 368: setup_tasks[platform] = config_entry.async_create_task(, please create a bug report at https://github.com/raman325/lock_code_manager/issues
2024-07-10 17:02:50.289 WARNING (MainThread) [homeassistant.helpers.frame] Detected code that calls async_forward_entry_setup for integration lock_code_manager with title: Main Doors and entry_id: 01J2FDP64980BQ1J8WXBVWF8EG, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1. Please report this issue.
Stack (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
sys.exit(main())
File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
handle._run()
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2122, in async_forward_entry_setup
_report_non_awaited_platform_forwards(entry, "async_forward_entry_setup")
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1175, in _report_non_awaited_platform_forwards
report(
File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 151, in report
_LOGGER.warning(msg, stack_info=True)

Screenshots

Screenshot 2024-07-10 at 5 15 39 PM

Anything else?

No response

mousedownmike avatar Jul 10 '24 23:07 mousedownmike

I should add that I don't think the integration worked for my doors. I just updated the YAML to add a code. After saving the configuration and waiting about 10 minutes, the code was not added to the door.

mousedownmike avatar Jul 10 '24 23:07 mousedownmike

I decided to give the integration a shot and started experiencing this as well. I haven't been able to find anything useful in my logs but I did find that web socket call to lock_code_manager/get_slot_calendar_data is returning an empty list of entities which causes the list of SlotMappings to many of it's fields set to undefined. In my case I have 1 entity setup so I'm not sure why this call is resulting in no results

amura11 avatar Aug 23 '24 13:08 amura11

I am having the same issue. Schlage Connect lock.

nholben avatar Sep 04 '24 15:09 nholben

Same issue. Schlage Connect zwave

tdiscenza avatar Feb 28 '25 02:02 tdiscenza

This issue has been fixed!

Fix Details:

The TypeError: e.pinActiveEntity is undefined error was fixed in commit 39ff8cf (October 2025).

Root Cause: The TypeScript code in generate-view.ts assumed that pinActiveEntity and codeEventEntity would always exist for every slot, but these entities might not be available during initial setup or if disabled.

Solution Implemented:

  1. Made codeEventEntity and pinActiveEntity optional in the SlotMapping interface
  2. Added conditional rendering to only include entities when they exist:
    ...(slotMapping.pinActiveEntity
        ? [{ entity: slotMapping.pinActiveEntity.entity_id, name: 'PIN active' }]
        : []),
    ...(slotMapping.codeEventEntity
        ? [{ entity: slotMapping.codeEventEntity.entity_id, name: 'PIN last used' }]
        : []),
    

The dashboard now gracefully handles missing entities without throwing errors.

Additional Fix: PR #594 adds even more defensive checks with optional chaining (?.entity_id) to handle edge cases.

Closing as fixed.

raman325 avatar Nov 03 '25 12:11 raman325