#RESTful switch: Anything wrong here? Where does the switch show up after reloading config?

1 messages · Page 1 of 1 (latest)

proud sigil
proud sigil
#

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?

#

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

#
#

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

  1. 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
#
  1. If the switch fails to show up as an Entity (under settings->entities), check logs. They usually contain an error of sorts
#
  1. X-Custom-Header is FAKE and a RED HERRING!! Under
    headers:
    MyWhateverHeader:"DATADATADATA"
karmic scroll