Fix set_state dropping False, 0, and None values#2594
Open
Ten0 wants to merge 1 commit intoAppDaemon:devfrom
Open
Fix set_state dropping False, 0, and None values#2594Ten0 wants to merge 1 commit intoAppDaemon:devfrom
Ten0 wants to merge 1 commit intoAppDaemon:devfrom
Conversation
Fixes AppDaemon#2531 Fixes AppDaemon#2464 Fixes AppDaemon#2492 Two bugs caused set_state (and other POST calls) to lose attribute values: 1. remove_literals used equality (==) to filter values, so 0 and 0.0 were removed alongside False (because 0 == False in Python). Fixed by switching to identity comparison (is). 2. clean_http_kwargs was applied globally to all HTTP methods, stripping False, None, and converting True to "true" even in POST JSON bodies where these are valid values. Replaced with a new self-contained clean_http_params_for_urlencode applied only to GET/DELETE query parameters; POST bodies are now passed transparently through the session's convert_json serializer. Removed the now-unused clean_kwargs function. Also: - Removed redundant clean_kwargs + remove_literals from websocket path; convert_json handles datetime serialization. - Performance tracking now computes actual payload size per HTTP method.
jsl12
approved these changes
Apr 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2531
Fixes #2464
Fixes #2492
Two bugs caused set_state (and other POST calls) to lose attribute values:
remove_literals used equality (==) to filter values, so 0 and 0.0 were removed alongside False (because 0 == False in Python). Fixed by switching to identity comparison (is).
clean_http_kwargs was applied globally to all HTTP methods, stripping False, None, and converting True to "true" even in POST JSON bodies where these are valid values. Replaced with a new self-contained clean_http_params_for_urlencode applied only to GET/DELETE query parameters; POST bodies are now passed transparently through the session's convert_json serializer. Removed the now-unused clean_kwargs function.
Also:
I have tested this on my own HomeAssistant instance, and this does indeed solve the issue and it seems my home finally works properly without triggering exceptions on 4.5 with that change, so I might finally update from 4.4 once this is released. 🎉