Skip to content
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

[Home Automation] Too many redirects error when HTTP request is made #121

Open
lanzer opened this issue May 14, 2024 · 3 comments
Open

[Home Automation] Too many redirects error when HTTP request is made #121

lanzer opened this issue May 14, 2024 · 3 comments

Comments

@lanzer
Copy link

lanzer commented May 14, 2024

The suggested home automation HTTP request with Node Red worked perfectly. However, every call ended up causing a "too many redirect" error and causing unnecessary bandwidth across network.

This issue is caused by the web interface issuing a redirect to refresh the admin panel so that it will reflect the new display state. However, if the display state have not changed (ie an action = off was sent but phoOS display is already set to off) , the web interface should not issue a redirect as nothing need to be refreshed. This will prevent the redirect error.

Tried scanning the code base on where this is implemented but no luck, sorry. :)

@avanc
Copy link
Owner

avanc commented May 14, 2024

Thanks for the detailed analysis. I'll keep this and close #118 as duplicate.

@avanc avanc mentioned this issue May 14, 2024
@lanzer
Copy link
Author

lanzer commented May 14, 2024

Sorry I had no idea where this file is in the code base but here's the simple fix:

/usr/lib/python3.8/site-packages/webui/plugins/display/display.py

line 31:

        if (self.get_body_argument("action")=="off"):
          if not isOn():
            return True
          setOn(False)
        elif (self.get_body_argument("action")=="on"):
          if isOn():
            return True
          setOn(True)

You already built the isOn function so it's super easy to leverage it and abort the redirect. :)

@lanzer
Copy link
Author

lanzer commented May 15, 2024

Whoops I had "return true" instead "return True", it's been a while since I worked on Python. :)

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

No branches or pull requests

2 participants