docs: Update State Boolean documentation to reflect actual case-sensitive behavior
The documentation incorrectly stated that Home Assistant State Boolean comparisons are case-insensitive, but the actual implementation is case-sensitive. This PR updates the documentation to accurately reflect the current behavior.
Changes
-
docs/node/config-server.md: Updated State Boolean section to clarify that:
- Configured state boolean values are normalized (lowercased and trimmed) when deployed
- Comparisons with entity states are case-sensitive
- Official HA integrations provide lowercase states, but user-defined entities (like
input_text) may have capitalized values that will not match
-
docs/guide/conditionals.md: Updated Home Assistant State Boolean section to:
- Add note about case-sensitive comparison behavior
- Recommend using static list or flow/global context for user-controlled entities with potentially capitalized states
Background
The issue reported that capitalized state values (e.g., True, Yes, Home) were not matching in habool comparisons. The documentation incorrectly claimed comparisons were case-insensitive, but the implementation is case-sensitive by design.
Actual Behavior
- Configured state boolean values (in server config) are normalized to lowercase when deployed
- Entity state comparisons are case-sensitive
- Official Home Assistant integrations provide lowercase states
- User-defined entities (like
input_text) may have capitalized states that won't match the lowercase boolean values
Original prompt
This section details on the original issue you should resolve
<issue_title>Current node if state logic not working for capitalised values</issue_title> <issue_description>### Describe the bug
The current state node with an If State configured as "in Home Assistant State Boolean" is not working when the state's value is capitalised, such as with
True,Yes,HomeorOpen. Each of these values evaluates to false and therefore outputs on the node's second output.This is contrary to the Home Assistant server node documentation, which state:
Comparisons are case-insensitive and ignore surrounding whitespace.
To Reproduce
This simple test harness:
With the following current state node setup:
Gives the following output:
- y -> true
- yes -> true
- true -> true
- on -> true
- home -> true
- open -> true
- Y -> false
- Yes -> false
- True -> false
- On -> false
- Home -> false
- Open -> false
Expected behavior
Capitalised states matching the set of Home Assistant State Boolean truthy values should equate to
trueand output on the current state node's first output.Environment Information
- Node-RED 4.1.1
- node-red-contrib-home-assistant-websocket 0.80.3
Additional context
- ComparatorService.getComparatorResult():73,
cValuetypically contains['y', 'yes', 'true', 'on', 'home', 'open']- ComparatorService.getComparatorResult():112 evaluates the comparison as
['y', 'yes', 'true', 'on', 'home', 'open'].includes('True') // falseactualValuecould be lowercased when used with includes/does_not_include for habool types</issue_description><agent_instructions>Notes about state booleans: Comparisons are not case-insensitive and ignore surround whitespace. The state boolean values are made lower case and surrounding spaces removed when the state boolean values are deployed so 'On' and 'on' become the same value and duplicates are removed.</agent_instructions>
Comments on the Issue (you are @copilot in this section)
@zachowj I believe all states coming from official Home Assistant integrations are lowercase. User-defined entities like `input_text` could technically be any case, so that might need to be considered. The original purpose of Home Assistant State Boolean was to let users group sensors, covers, doors, and similar entities into shared condition logic. Once we start including additional entity types, the behavior becomes less clear. If someone is working with a user-controlled entity, a static list or a flow/global context value may be the better option.Right now I’m not sure what the best long-term approach is.
- Fixes zachowj/node-red-contrib-home-assistant-websocket#1931
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.