POST variables to Telegram webhook

Using these infos, I’m trying to send some parameters via POST.
I put this code into configuration.yaml:

rest_command:
  telegram_notify_door:
    url: "https://webhooks.site.com/home_assistant.php"
    method: POST
    content_type: "application/x-www-form-urlencoded"
    payload: "auth=hash&door={{ door }}&status={{ status }}"

And the action:

action:
  - service: rest_command.telegram_notify_door
    data:
      door: "{{ trigger.to_state.name }}"
      status: "{{ 'OPEN' if trigger.to_state.state == 'on' else 'CLOSED' }}"

But online I didn’t see any call.
Any ideas?

Title is misleading. Seems about telegram, not SNZP-06

@francisp ops sorry.

has anyone ever tried to use rest_command with a POST method?

Your payload looks like a GET query-style payload. Should that be in the URL?

I would expect a POST payload to look like a dictionary. See this example:

do you mean that it must always be in json format?

What is the endpoint of your POST request expecting?

I’m just debugging using this code

    debug("--- ".date("Y-m-d H:i:s")." ----------------------\n");
    debug("\$_GET: ".print_r($_GET, 1)."\n\n");
    debug("\$_POST: ".print_r($_POST, 1)."\n\n");
    debug("\$_FILES: ".print_r($_FILES, 1)."\n\n");

the debug function

// print debug
function debug($msg) {
  $fd = fopen(__DIR__."/debug.log", "a");
  fwrite($fd, $msg);
  fclose($fd);
}

so I can read via terminal using tail -f debug.log

Using this conf

rest_command:
  telegram_notify_door:
    url: "https://webhooks.site.com/home_assistant.php?gvar=aaa"
    method: POST
    payload: 'pvar=bbb'

I can see the $_GET var but $_POST is empty.

--- 2024-07-10 06:34:40 ----------------------
$_GET: Array
(
    [gvar] => aaa
)


$_POST: Array
(
)


$_FILES: Array
(
)

Using json doesn’t make any differences.

Have you validated your PHP script using e.g. curl ensure $_POST is working? I assume you’re substituting your real domain name into the url.

no problems using curl

curl -X POST -d "pvar=bbb" https://webhooks.site.com/home_assistant.php?gvar=aaa

debug.log

--- 2024-07-10 07:43:06 ----------------------
$_GET: Array
(
    [gvar] => aaa
)


$_POST: Array
(
    [pvar] => bbb
)


$_FILES: Array
(
)

It’s ridiculous… even if I copy/paste the example code from the home assistant documentation, it doesn’t work.
I thinking the post method does not work at all.