jasoncoon / esp8266-fastled-webserver

GNU General Public License v3.0
714 stars 359 forks source link

Simple HTTP post to power on and off #162

Closed jakesza closed 4 years ago

jakesza commented 4 years ago

Hi, I am trying to do a http post to http://esp8266fastled//power=1 or something alike to create a power switch on homebridge by using an http post.

Can you please send me in the right direction?

Panoramiac commented 4 years ago

Hi jakesza,

I had the same issue yesterday sending a HTTP POST request to the wemos. It is not working as you write. It is not working just with the browser. You need to use a tool to create the POST request (I got the hint from a friend). Under Linux you can use curl (you need to use the IP of your device of course (under windows you could search for postman, but I did not use it so far):

curl -d "value=1" -X POST http://192.168.178.92/power

Since I never used homebridge so far, I do not know how to set up there, but it should be similar. If you are interested, I can also explain a basic setup for Node Red, this is currently my construction side ;-).

Good luck, Tobias

jakesza commented 4 years ago

Hi jakesza,

I had the same issue yesterday sending a HTTP POST request to the wemos. It is not working as you write. It is not working just with the browser. You need to use a tool to create the POST request (I got the hint from a friend). Under Linux you can use curl (you need to use the IP of your device of course (under windows you could search for postman, but I did not use it so far):

curl -d "value=1" -X POST http://192.168.178.92/power

Since I never used homebridge so far, I do not know how to set up there, but it should be similar. If you are interested, I can also explain a basic setup for Node Red, this is currently my construction side ;-).

Good luck, Tobias

Hi Tobias. Thanks for the tips. I need to automate this because currently one has to manually on and off the eap8266webserver. I already use nodered but also cannot automate that into homekit.

I found a plugin on homebridge that can do Http switches just need to figure out how to use it on this.

jakesza commented 4 years ago

Here is the http switch

https://www.npmjs.com/package/homebridge-http-switch

Panoramiac commented 4 years ago

To get it working with Node red you could use this:

https://flows.nodered.org/node/node-red-contrib-homebridge-automation

Just googled it. Usuallay to get NR to talk to other services is quite simple. I installed for example the Tasmota plugin and can easly control it via MQTT.

tobi01001 commented 4 years ago

I was running into quite the same challenges and decided to modify the behaviour to use a standard HTTP_GET call for the web-server. This way I can modify (almost) everything with a single HTTP call like e.g. http://esp.address/set?mo=2&pa=3&sp=1000 -> this would set mode (effect) number 2, color palette number 3 and a speed setting of 1000.

The webservers answers with the values being set in JSON format. e.g.: {"currentState":{"wsfxmode_Num":2,"wsfxmode":"Ease Twinkle","state":"on","power":true,"palette_num":3,"palette_name":"RainbowStripe Colors","palette_count":21,"speed":1000,"beat88":1000}}

Power could be set the same way with http://esp.address/set?power=1 (or 0 respectively). (I do automate with fhem, but it should work with homebridge as well.)

Its a heavily modifed version of this code, its grown a lot and has some specifics (i.e. uses DMA for driving the LEDs). Other than that, I have 5 Lamps continously running and automated with this.

I do not know if its appropriate to post that here but if it helps your problem and if you would like to have a look: https://github.com/tobi01001/LED_Stripe_Dynamic_web_conf

jakesza commented 4 years ago

This “ Power could be set the same way with http://esp.address/set?power=1 (or 0 respectively).” will def work.

I will try this. Thanks!

jakesza commented 4 years ago

curl -d "value=1" -X POST http://192.168.178.92/power

works 💯 Thanks.

jakesza commented 4 years ago

Hi jakesza, I had the same issue yesterday sending a HTTP POST request to the wemos. It is not working as you write. It is not working just with the browser. You need to use a tool to create the POST request (I got the hint from a friend). Under Linux you can use curl (you need to use the IP of your device of course (under windows you could search for postman, but I did not use it so far): curl -d "value=1" -X POST http://192.168.178.92/power Since I never used homebridge so far, I do not know how to set up there, but it should be similar. If you are interested, I can also explain a basic setup for Node Red, this is currently my construction side ;-). Good luck, Tobias

Hi Tobias. Thanks for the tips. I need to automate this because currently one has to manually on and off the eap8266webserver. I already use nodered but also cannot automate that into homekit.

I found a plugin on homebridge that can do Http switches just need to figure out how to use it on this.

Do you perhaps know what the command would be to check the power state?

Panoramiac commented 4 years ago

I now use wled with its android app and the home assistant integration. Works without a lot of config stuff. About your question I need to check later. With /all you can get the state of everything.

jasoncoon commented 4 years ago

Closing, reopen if needed.