Open lanzer opened 6 months ago
Thanks for the detailed analysis. I'll keep this and close #118 as duplicate.
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. :)
Whoops I had "return true" instead "return True", it's been a while since I worked on Python. :)
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. :)