Skip to content

Code formatting improvements for sentence.py#370

Closed
Copilot wants to merge 6 commits intomainfrom
copilot/fix-update-config-for-number
Closed

Code formatting improvements for sentence.py#370
Copilot wants to merge 6 commits intomainfrom
copilot/fix-update-config-for-number

Conversation

Copy link

Copilot AI commented Dec 8, 2025

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.TimeoutError to TimeoutError (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

  1. Create an "update config" node and select a sensor node.
  2. Pass it a payload to do something simple, like change the icon to a light bulb ("icon": "mdi:lightbulb")
  3. Confirm it works fine
  4. Change to a number node instead of a sensor node.
  5. 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

image image

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)


💡 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 AI and others added 2 commits December 8, 2025 00:33
Co-authored-by: zachowj <37859597+zachowj@users.noreply.github.com>
…e access

Co-authored-by: zachowj <37859597+zachowj@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix update config node for number entity attributes Fix update config node for number entities Dec 8, 2025
Copilot AI requested a review from zachowj December 8, 2025 00:38
@zachowj
Copy link
Owner

zachowj commented Dec 8, 2025

@copilot Need to fix linting issues

Co-authored-by: zachowj <37859597+zachowj@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 8, 2025

@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.

@zachowj
Copy link
Owner

zachowj commented Dec 9, 2025

@copilot resolve conficts and update to use new ruff rules

Co-authored-by: zachowj <37859597+zachowj@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 9, 2025

@copilot resolve conficts and update to use new ruff rules

Resolved in 84a8937. Merged latest main branch changes including:

  • New .ruff.toml configuration 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

@zachowj
Copy link
Owner

zachowj commented Dec 9, 2025

@copilot Need to rebase with current main branch

Copy link
Author

Copilot AI commented Dec 9, 2025

@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

@zachowj
Copy link
Owner

zachowj commented Dec 9, 2025

@copilot remove all changes except for those in sentence.py and tests/test_sentence.py

Co-authored-by: zachowj <37859597+zachowj@users.noreply.github.com>
Copilot AI changed the title Fix update config node for number entities Code formatting improvements for sentence.py Dec 9, 2025
@zachowj zachowj closed this Jan 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The "update config" node does not work for any attributes for the "number" entities

2 participants

Comments