Quick question about POST requests to ESPhome device

My overall goal is to have my sonoff rf bridge flashed with tasmota send REST API commands directly to my home-built ESPhome devices, without going through an MQTT broker. However, that means I first have to understand how to send a POST request to the esp device. If I send:
It returns
which is great. But if I send,
(or turn_off’) it does not change the state of the light. My understanding from the documentation is that should toggle the state. Can anyone tell me what I am missing?
(If anyone has accomplished something similar to my overarching goal, I will take help there, too!)

Does turn_on work. (with or without setting bright,ness?)

No, it does not turn on. BTW, it is really just a relay that I have set up so:

# Light Bulb Relay
  - platform: gpio
    pin: D7
    id: lamprelay2

# Light entity
  - platform: binary
    id: lamp_light2
    name: $entity_name
    output: lamprelay2

What does the log say?

The console doesn’t register anything.

How are you sending the rest commands?

I want to ultimately send them via tasmota rules, but right now just through a browser.

Just from the address bar? That is a GET not a POST I think.

Yeah, I think that you are right. I was hoping for a simple check that all my syntax was right.
It is probably OK, since the GET works. I just need to figure out how to send this via tasmota.

There is a simple way. I installed httpie (linux) and then ran

$ http POST
HTTP/1.1 200 OK
Accept-Ranges: none
Connection: close
Content-Length: 0

and it works fine.

1 Like