Интеграция между Shelly и Telegram через Webhook
Я пытался интегрироваться между Shelly и Telegram.
В Telegram есть опция webhook , которая означает, что если бот Telegram получил сообщение, это сообщение автоматически переместится на другой сервер:
Чтобы открыть ретранслятор Shelly, я могу отправить POST ( doc ):
curl -X POST https://shelly-54-eu.shelly.cloud/device/relay/control -d "channel=0&turn=on&id=<Shelly_id>&auth_key=<Shelly_auth_key>"
Я попытался реализовать с помощью wehbook перенаправление для облака Shelly, поэтому, когда мой бот телеграммы получит сообщение, моя Шелли откроет реле.
Я попытался установить веб-хук следующим образом:
curl -X POST https://api.telegram.org/bot<telegam_bot_token>/setWebhook --data-urlencode "url=https://shelly-54-eu.shelly.cloud/device/relay/control?channel=0&turn=on&id=<Shelly_id>&auth_key=<Shelly_auth_key>"
Но когда я смотрю на URL-адрес getWebhookInfo::, я вижу:
{"ok":true,"result":{"url":"https://shelly-54-eu.shelly.cloud/device/relay/control?channel=0&turn=on&id=<Shelly_id>&auth_key=<Shelly_auth_key>","has_custom_certificate":false,"pending_update_count":5,"last_error_date":1670102630,"last_error_message":"Wrong response from the webhook: 401 Unauthorized","max_connections":40,"ip_address":"<Shelly_ip>"}}
.
Если я заменю--data-urlencode
с-d
:
curl -X POST https://api.telegram.org/bot<telegam_bot_token>/setWebhook -d "url=https://shelly-54-eu.shelly.cloud/device/relay/control?channel=0&turn=on&id=<Shelly_id>&auth_key=<Shelly_auth_key>"
Такhttps://api.telegram.org/bot<Tlegram_token>/getWebhookInfo
возвращаться
{"ok":true,"result":{"url":"https://shelly-54-eu.shelly.cloud/device/relay/control?channel=0","has_custom_certificate":false,"pending_update_count":1,"last_error_date":1670263360,"last_error_message":"Wrong response from the webhook: 401 Unauthorized","max_connections":40,"ip_address":"<Shelly_ip>"}}
Видимо проблема в том, что сервер Shelly ожидал получитьchannel=0&turn=on&id=<Shelly_id>&auth_key=<Shelly_auth_key>
как "данные", а не через URL,
Есть ли способ передать эти данные с помощью веб-хука Telegram?