#RESTful switch: Anything wrong here? Where does the switch show up after reloading config?
1 messages · Page 1 of 1 (latest)
Does anybody have any idea of how do I test this? Make this do something? Click it?
Works fine in a browser
But no button, no device, no entity in HA. The documentation doesn't say the switch needs anything more
configuration is apparently valid, HA loads fine
RESTful switch: Anything wrong here? Where does the switch show up after reloading config?
Looking at other examples of RESTful switch it looks fine-ish
https://gist.github.com/LarsBergqvist/5418e554bd2a301db705c319ef0ec4b4
Some dude is adding this extra code on top
Do I need this if I want to see the switch in lovelace? Or without this, ought it just barf it up in some random place?
Ok, maybe I'm just trying something too ambitious
This should expose a switch called ZIGGY, yes? no?
I know it won't work
but it should display the switch, right?
Okay well in the logs it says
2024-10-08 00:13:58.056 ERROR (MainThread) [homeassistant.components.rest.switch] Got non-ok response from resource: 403
which appears to indicate the switch needs to do a successful GET before it registers it in HA
OBVIOUSLY, why would that need mentioning in the documentation. I mean duh.
So the issue must be with the x-header format
Ha, looks like I'm not alone https://community.home-assistant.io/t/rest-switch-not-showing-up/200078
Hi there, As you might guess from this post I’m an absolute beginner with HA. I’m trying to add one Shelly 1 to Home Assistant and to do so I’m trying to set up a RESTfull switch. The thing is that the configuration seems to be correct however the switch does not show up anywhere (entities and dev tools). I’ve already restarted HA several time...
still no clue how to specify a custom header
of course, there doesn't seem to be any documentation on how to supply a custom header in x-custom-header
2024-10-08 00:29:54.529 WARNING (MainThread) [homeassistant.components.switch] Platform rest not ready yet: No route to resource/endpoint: http://octopi.home/api/plugin/octolight; Retrying in background in 30 seconds
I'm not sure if this is how I should be transferring the header or not, but it changes something.
headers:
Content-Type: application/json
X-Api-Key: "asdfsdfasdfasdfasdf"
YESSSSSSSSSS
It works!!!
A big fat thanks to the HA community for all the help
For anybody else
- The RESTful switch will NOT show anywhere if it fails to establish a 200 OK. The hostname could be bad, the hostname could be correct and not have http/s open, the former could be true but wrong auth, right auth but returns non-JSON... ANYTHING goes wrong and the switch won't show up. Not in entities, devices, lovelace, anywhere
- If the switch fails to show up as an Entity (under settings->entities), check logs. They usually contain an error of sorts
- X-Custom-Header is FAKE and a RED HERRING!! Under
headers:
MyWhateverHeader:"DATADATADATA"
