Skip to content
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

[Commands] Add PostToHTTP command #4465

Merged
merged 3 commits into from
Jan 18, 2023

Conversation

tonhuisman
Copy link
Contributor

@tonhuisman tonhuisman commented Jan 15, 2023

Resolves #4446

Add support for command PostToHTTP <host>,<port>,<path>,[<headers>][,<postbody>]

Features:

  • Send data to an external host via the HTTP POST verb.
  • Support for Authorization:
    • Basic by supplying <user>:<password>@<host>.
    • Others like Bearer by supplying the required data via headers ("Authorization: Bearer <token>").
  • Optional multiple headers, separated using the %LF% variable.
  • Documentation updated

NB: Not included in the Minimal builds.

TODO:

  • Testing (tested locally already)

@chromoxdor
Copy link
Contributor

did some testing. works fine but i couldn´t test authorization...

@Budman1758
Copy link

Budman1758 commented Jan 18, 2023

Just tested this and seems to work fine. Could not test authorization either though.
NB: Not included in the Minimal builds.
Is it included in the 2meg builds? I use that build on some smart plugs.

@Budman1758
Copy link

Budman1758 commented Jan 18, 2023

Well....Weirdness. I set the unit up and the commands were working ok. Several hours later I was testing again and kept getting a 404 error using my self hosted server. Tried ntfy's public server and it posted ok. All my other devices here were still connecting fine to my server.
I went to my test unit and decided to set it for a static IP so I could use my Pi-Hole dns. Upon rebooting the unit to set the static IP it went into a boot loop. Flashed it with a blank bin and reflashed the binary. Went to set static IP, reboot, boot loop again..... Using the normal 4M1M bin file from[ this action run
I will try another bin from that batch and see what happens.

` --------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (9):
epc1=0x40294f68 epc2=0x00000000 epc3=0x00000000 excvaddr=0x3fff1b76 depc=0x00000000

stack>>>

ctx: cont
sp: 3fff30e0 end: 3fff3410 offset: 0190
3fff3270: 3fff64cc 00000001 3fff32a0 0000002f
3fff3280: 00002800 00000500 00000500 4010133b
3fff3290: 402c61fe 3fff1288 00000001 00000001
3fff32a0: 40204024 00000001 00000020 401015f3
3fff32b0: 402c61fe 40295a80 d201a8c0 40295a80
3fff32c0: 00ffffff 40295a80 fe01a8c0 40295a80
3fff32d0: d801a8c0 0010001f 3fff1288 0000002f
3fff32e0: 3fff2088 00000001 3fff1288 40240cc6
3fff32f0: 3fff6400 0010001f 80ff1288 4023658c
3fff3300: 3fff2088 3fff1580 3fff1288 40240e29
3fff3310: 6e6f7242 6544657a 8a007265 54565178
3fff3320: 33373252 8a005152 000027bb fffffff1
3fff3330: 00000001 e0b44b6c 0401c4fe 00000000
3fff3340: 40000000 3fff6400 0033003f 80007265
3fff3350: 40200000 40205440 80ff11f8 3fff6400
3fff3360: 0000005f 80000001 3fff1288 4023fca0
3fff3370: 009fbc6c 3ffe8548 3fff1288 40241012
3fff3380: 3fff2088 3ffe8548 3fff11b0 0000002f
3fff3390: 3fff2088 3ffe8548 3fff1b60 4023d135
3fff33a0: 3fff2088 3ffe8548 3fff1b60 40244347
3fff33b0: 3fff6600 004d004f 80ef0000 3fff3e00
3fff33c0: 0000006f 80efeffe feefeffe feefeffe
3fff33d0: feefeffe feefeffe feefeffe 3fff345c
3fff33e0: 3fffdad0 00000000 3fff3418 4020ce48
3fff33f0: feefeffe feefeffe feefeffe 4028888f
3fff3400: feefeffe feefeffe 3ffe869c 401004f9
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3584, room 16
tail 0
chksum 0xb0
csum 0xb0
v2843a5ac
~ld
▒U309 : Info : WIFI : Set WiFi to AP+STA
5092 : Info : WIFI : Set WiFi to OFF
5308 : Info :

INIT : Booting version: ESP_Easy_mega_20230115_normal_ESP8266_4M1M, (GitHub Actions) HEAD_7918e7e (ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support)
5309 : Info : INIT : Free RAM:26504
5311 : Info : INIT : Exception #30 Last Action before Reboot: Intended Reboot: CommandReboot Last systime: 112 - Restart Reason: Exception
5312 : Info : FS : Mounting...
5338 : Info : FS : Mount successful, used 75802 bytes of 957314
5357 : Info : CRC : Settings CRC ...OK
5360 : Info : CRC : SecuritySettings CRC ...OK
5363 : Info : INIT : I2C
5365 : Info : INIT : SPI not enabled
`

@tonhuisman
Copy link
Contributor Author

TD-er merged a PR today that will most likely fix this (have to verify still, in a short while), just pulled in the mega branch, so you can get an update from the Actions run once that's finished.

@Budman1758
Copy link

Budman1758 commented Jan 18, 2023

Sorry to say but still getting boot loop. 4M1M normal.
Will try another bin file

EDIT:
ESP_Easy_mega_20230118_custom_alt_wifi_ESP8266_4M1M

Same thing. Set static IP. Reboot. Boot loop

Edit 2:
Still having the 404 error issue. Will try reinstalling ntfy server on my end. I did not change anything on it though. Easy to reinstall as its a container on my proxmox box

@tonhuisman
Copy link
Contributor Author

Upon rebooting the unit to set the static IP it went into a boot loop.

If you restore it to use DHCP it will be able to boot again, using the latest build from this PR. (WIP)

@Budman1758
Copy link

Will do that and keep testing the ntfy stuff

@tonhuisman
Copy link
Contributor Author

If you restore it to use DHCP it will be able to boot again

The failure is caused by an issue in the Arduino libraries for ESP8266, and will be resolved with a workaround via #4468

@Budman1758
Copy link

Budman1758 commented Jan 18, 2023

Figured out my 404 issue. Config problem on my end. Router misconfig.
ntfy post is working as it was / should.

@TD-er TD-er merged commit 4fb32da into letscontrolit:mega Jan 18, 2023
@Budman1758
Copy link

A side note. Just noticed there is no notifications page in the build I am using. Is that by design?

@tonhuisman tonhuisman deleted the feature/PostToHTTP-command branch January 19, 2023 06:34
@tonhuisman
Copy link
Contributor Author

there is no notifications page in the build I am using.

Notifiers are excluded from some builds, most notably from MINIMAL, as is to be expected, but also the 1M builds, and for CUSTOM builds that have the VCC option enabled.
Search for NOTIFIER_SET_NONE in https://github.com/letscontrolit/ESPEasy/blob/mega/src/src/CustomBuild/define_plugin_sets.h to find the exact spots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add PostToHTTP command for HTTP POST
4 participants