-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic reloading broken on recently added displays. #140
Conversation
…r in the logs because (most likely) num_pages contains a string, while page contains an int, resulting in a python type error
Could you please provide a log of the error ? I would prefer to trace to error to the source then to fix where we find the symptom |
I reintroduced the bug but added a comment with the actual fix. the line numbers beyond 559 are +1 instead of the actual lines in the trace. |
Page is already being tested against zero (so should already be a number). Does it really need to be cast to an int for the test against num_pages ? |
As you can see in the error log, it seems to be able to have more then just an int, so the change helps to fix this.
It shows 'page' can hold a string called 'all'. There is no type cast on 'num_pages' when it is filled. |
Skipping through the code in the component, I can conclude BOTH 'page' and 'num_pages' hold a string initially.
HASP_NUM_PAGES is set with the discovered number of pages here:
We can actually conclude this is pretty much guaranteed an int as HASP_NUM_PAGES in self._statusupdate is set using the discovered 'CONF_PAGES'. So it is 'page' that can hold the string 'all' which does not allow a 'larger then' int comparison. That is the one which needs a workaround in that check. |
Updated the code to check 'page' for the type int instead of casting both to it. This should satisfy the check in every possible way and not throw exceptions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The fix seems to not be complete. Somehow num_pages can hold a string as well... 🤔 |
The display stops or refuses to dynamically update (from HA) and throws an error in the logs because (most likely) num_pages contains a string, while page contains an int, resulting in a python type error.