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
RESTful switch failing to initialize (GET request validation failing on a POST resource) #7431
Comments
Your resource is returning a 404 (Not Found) error. It seems to be that Home Assistant is doing the right thing here...? |
Yeah, not sure, I'm somewhat out of my depth here. When a GET request is done on the resource path it returns a 404, send it a POST and it will return 200 OK. So it's not to say this Home Assistant component isn't doing things correct, but I'm hoping for a way that I as the user can configure it to pass on the validation in setup; perhaps specify a second "status" URL for it to do its GET request on...? |
So i have this issue since the update as well. I take it the Home Assistant is now checking this platform/feature/api rather than before it was just accepting it and not testing for a response ? |
As a note i have link here from the other guide i followed on how to set this up HASS side. |
How does HASS get the state of the switch if LIRC doesn't respond to GET requests? |
Well... I guess in this case, it just doesn't, eh? It's firing an IR command and assuming the state updates. There is no state to retrieve. This validation obviously won't work for these sorts of cases. |
The issue here is that not all REST switches support GETs for the state. Some of them (like LIRC) operate in de facto 'optimistic' mode. It's not a safe assumption that an otherwise functional switch will support GETs. I see several paths forwards here:
Thoughts? |
My vote is for optimistic mode, |
as a side note i can snapshot my Home Assistant (it's running under a hyper-v virtual) and test a fix if you require. |
An optimistic option would work well for me. huh, that or we are shoehorning this lirc setup into the wrong type of thing? (I'm fairly new to Home Assistant) is there a better component type to make this work? A single fire, button type that would show up in the front end? |
Potential solution: #4937 Optimistic mode is a good alternative that is obviously less work. |
Please I am new to home assistant and having a problem I have been unable to fix for days as regards the restful switch. I have added the switch to my configuration file, but it doesn't show up on the UI and this shows on the status "ERROR (MainThread) [homeassistant.components.switch.rest] Got non-ok response from resource: 404". Please anyway to solve this? Regards |
I can't find where i found the fix, must have been on anther post. I have back tracked my fix i found from someone on here. If you want to ignore the error and setup the item any way on the terminal edit this file. I used VIM as it has a handy line counter at the bottom right, tho it's not as simple to use as nano. |
This get changed to
note that after an upgrade this get over written so you will need to redo it, if required. |
Hello, Many thanks for the help, and I really appreciate it. It worked and my problem of several weeks have been solved 👯♂️ Kind regards |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 |
I'm unable to test as i no longer have my PI running this. |
Just thought I'd share a workaround/different way of doing this - use the RESTful Command instead of a switch: This lets you create a service that can POST to a URL without having to be able to GET from it. I think doing it this way also makes a bit more sense in this situation, and saves you from having to customise the HA code... |
Just updated from 48.1 to 54.0 and have the same issue. rest.py has been changed a bit so I'm unable to try the workaround by commenting out the false return. |
Used the rest.py from commit #8004 before HTTP auth was added and was able to find and comment out the line which is now on line 73 for anyone else running into this. |
Transient network outage can also cause GET request during init to fail. This leads into situation where restful switch is not initialized at all and only way to recover is to restart hass. It might be better to consider the situation as warning, not error. |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 |
This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍 |
Home Assistant release (
hass --version
):Currently running 0.43.2 -- looks like issue came with 0.42 (commit aiohttp 2 #6835)
Python release (
python3 --version
):python3.4
Component/platform:
switch/rest
Description of problem:
I have a few rest switchs configured where the resource is a POST to an lirc_web server. After updating to 0.43.2 those switches no longer get initialized after a reboot.
Seeing that there is a new request validation at https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/switch/rest.py#L64
I went into my local installation and commented out the return False to keep it from failing the initialization.
Expected:
Need more specific validation to allow a POST resource, or perhaps a way to specify it in the configuration.
Problem-relevant
configuration.yaml
entries and steps to reproduce:Traceback (if applicable):
Additional info:
I hope I explained everything correctly. I'd attempt to fix it myself, but am unsure of the correct way to handle it. Thanks!
The text was updated successfully, but these errors were encountered: