Fix: Add null safety for doorState property to prevent crash with Yale Assure Lock 2 #165
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The plugin was crashing with
Cannot read properties of undefined (reading 'includes')
when used with Yale Assure Lock 2 devices. The issue occurred because the lock's API response contains a lockStatus object like{"status":"unknown"}
without adoorState
property, but the code assumed this property would always exist.The crash happened in the
parseStatus
method when trying to call.includes()
on the undefineddoorState
:The fix adds optional chaining to safely handle cases where
doorState
is undefined:This minimal change:
doorState
doorState
The contact sensor functionality will fall back to the existing
ContactSensorState
whendoorState
is unavailable, ensuring the plugin remains functional even without door state information.Fixes #127.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.