API POST has new state validation (fix for state = 0)#8324
Merged
Conversation
|
@azogue, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @JshWright and @fabaff to be potential reviewers. |
pvizeli
approved these changes
Jul 3, 2017
balloob
pushed a commit
that referenced
this pull request
Jul 5, 2017
* Fix validation of get new state * Add unittest to check posting a state with zero value
Member
|
Cherry picked for 0.48.1 |
Merged
Merged
dethpickle
pushed a commit
to dethpickle/home-assistant
that referenced
this pull request
Aug 18, 2017
…#8324) * Fix validation of get new state * Add unittest to check posting a state with zero value
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description:
When posting a new state of an entity through the API, if the state value is
0, the validation acts as if a state had not been sent, so it returns a 404 error code and does not update the entity state.Problem is this validation:
If
new_stateis a float or an integer, the0 / 0.0value returns the error! This has to be a null comparison (if new_state is None).I was going crazy until I discovered the error... I have a custom sensor in an AppDaemon app which measures the difference of temperature between the interior and the exterior of the house, and it was failing mysteriously when ∆T=0.
Example entry to check the error:
Checklist:
If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests pass