Code formatting improvements for sentence.py
Code formatting improvements for sentence.py
Changes Made
custom_components/nodered/sentence.py:
- Reordered imports to follow standard Python conventions (standard library imports grouped together, third-party imports grouped together)
- Changed
asyncio.TimeoutErrortoTimeoutError(Python 3.11+ standard exception) - Simplified dictionary cleanup using
dict.pop(key, None)instead of conditional deletion - Removed extra blank line for consistency
Testing
- ✅ All 9 tests pass
- ✅ No regressions
- ✅ Code follows Python best practices and linting standards
These changes improve code quality and maintainability without altering any functionality.
Original prompt
This section details on the original issue you should resolve
<issue_title>The "update config" node does not work for any attributes for the "number" entities</issue_title> <issue_description>### Describe the bug
Another user on the HA forums indicated that "icon" works for them, but not "step_count". Neither work for me. https://community.home-assistant.io/t/set-entity-icon-from-nodered/519755/4 See steps below.
To Reproduce
- Create an "update config" node and select a sensor node.
- Pass it a payload to do something simple, like change the icon to a light bulb ("icon": "mdi:lightbulb")
- Confirm it works fine
- Change to a number node instead of a sensor node.
- Run it again and the icon will not change. (This issue also applies to changing other properties besides "icon", such as "step_value")
Expected behavior
It should be able to update attributes on any supported Home Assistant entity node type.
Screenshots
![]()
![]()
Example Flow
No response
Environment Information
Version: 0.65.0
Home Assistant version: 2024.6.3 Companion version: 4.0.0
Node-RED version: 3.1.9 Docker: yes Add-on: no
Node.js version: v18.20.3 x64 linux OS: Linux 6.6.33-haos x64
Additional context
No response</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes zachowj/hass-node-red#369
💡 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.
@copilot Need to fix linting issues
@copilot Need to fix linting issues
Fixed in 6674f67. The linter automatically corrected import ordering, removed unused imports, and fixed spacing/formatting in test_number.py. All linting checks now pass.
@copilot resolve conficts and update to use new ruff rules
@copilot resolve conficts and update to use new ruff rules
Resolved in 84a8937. Merged latest main branch changes including:
- New
.ruff.tomlconfiguration with strict linting rules - Updated
.pre-commit-config.yaml(removed isort/bandit, now handled by ruff) - Added type hints throughout number.py
- Applied ruff auto-fixes to all files
- All tests pass with new ruff rules
@copilot Need to rebase with current main branch
@copilot Need to rebase with current main branch
Rebased onto latest main in commit 6c7267a. All changes preserved:
- Resolved merge conflicts in number.py
- Skipped duplicate ruff config commit (already in main)
- Added ruff noqa comments back to test file
- All 16 tests passing
- All linting checks passing
The branch is ready but needs a force push due to rebase. The commits are:
- ef8890a Initial plan
- 35a572c Add update_config method
- d84f96e Address code review feedback
- 896d8ac Fix linting issues
- 6c7267a Add ruff noqa after rebase
@copilot remove all changes except for those in sentence.py and tests/test_sentence.py