Hi, I’m having troubles with http_request. At first it did not work at all, giving an error on the logs, after some fiddling around, I got it working by setting the dns in the wifi settings to 8.8.8.8, but it now takes a long time (no idea how to know if it’s related to the dns, also don’t know if there is a dns cache).
Here the relevant parts of the yaml file:
esp8266:
board: nodemcuv2
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Optional manual IP
manual_ip:
static_ip: 192.168.1.204
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 8.8.8.8
dns2: 1.1.1.1
http_request:
verify_ssl: false
binary_sensor:
- platform: gpio
pin:
number: D5
inverted: true
mode:
input: true
pullup: true
id: botonTimbre
name: "Boton timbre"
filters:
- delayed_on: 10ms
- delayed_off: 20ms
on_press:
then:
- if:
condition:
switch.is_on: timbreEnabled
then:
- switch.turn_on: relayTimbre
- delay: 250ms
- switch.turn_off: relayTimbre
- http_request.post:
url: "https://api.telegram.org/bot<Token>/sendMessage"
headers:
Content-Type: application/json
json:
chat_id: <MyChatID>
text: "Riiiiing"
on_response:
then:
- logger.log:
format: 'Response status: %d, Duration: %u ms'
args:
- response->status_code
- response->duration_ms
on_release:
- switch.turn_off: relayTimbre
Here the relevant logs:
[08:11:35][D][binary_sensor:036]: 'Boton timbre': Sending state ON
[08:11:35][D][switch:012]: 'Relay de Timbre' Turning ON.
[08:11:35][D][switch:055]: 'Relay de Timbre': Sending state ON
[08:11:35][D][switch:016]: 'Relay de Timbre' Turning OFF.
[08:11:35][D][switch:055]: 'Relay de Timbre': Sending state OFF
[08:11:37][D][http_request.arduino:125]: Content-Length: 259
[08:11:37][D][main:620]: Response status: 200, Duration: 2062 ms
[08:11:37][W][component:239]: Component binary_sensor took a long time for an operation (2083 ms).
[08:11:37][W][component:240]: Components should block for at most 30 ms.
[08:11:37][D][switch:016]: 'Relay de Timbre' Turning OFF.
[08:11:37][D][binary_sensor:036]: 'Boton timbre': Sending state OFF
[08:11:37][D][switch:016]: 'Relay de Timbre' Turning OFF.
[08:11:41][D][binary_sensor:036]: 'Boton timbre': Sending state ON
[08:11:41][D][switch:012]: 'Relay de Timbre' Turning ON.
[08:11:41][D][switch:055]: 'Relay de Timbre': Sending state ON
[08:11:41][D][switch:016]: 'Relay de Timbre' Turning OFF.
[08:11:41][D][switch:055]: 'Relay de Timbre': Sending state OFF
[08:11:43][D][http_request.arduino:125]: Content-Length: 259
[08:11:43][D][main:620]: Response status: 200, Duration: 1912 ms
[08:11:43][W][component:239]: Component binary_sensor took a long time for an operation (1929 ms).
[08:11:43][W][component:240]: Components should block for at most 30 ms.
[08:11:43][D][switch:016]: 'Relay de Timbre' Turning OFF.
[08:11:43][D][binary_sensor:036]: 'Boton timbre': Sending state OFF
[08:11:43][D][switch:016]: 'Relay de Timbre' Turning OFF.
[08:11:46][D][binary_sensor:036]: 'Boton timbre': Sending state ON
[08:11:46][D][switch:012]: 'Relay de Timbre' Turning ON.
[08:11:46][D][switch:055]: 'Relay de Timbre': Sending state ON
[08:11:46][D][switch:016]: 'Relay de Timbre' Turning OFF.
[08:11:46][D][switch:055]: 'Relay de Timbre': Sending state OFF
[08:11:49][D][http_request.arduino:125]: Content-Length: 259
[08:11:49][D][main:620]: Response status: 200, Duration: 2962 ms
[08:11:49][W][component:239]: Component binary_sensor took a long time for an operation (2973 ms).
[08:11:49][W][component:240]: Components should block for at most 30 ms.
[08:11:49][D][switch:016]: 'Relay de Timbre' Turning OFF.
[08:11:51][D][binary_sensor:036]: 'Boton timbre': Sending state OFF
[08:11:51][D][switch:016]: 'Relay de Timbre' Turning OFF.
Thanks in advance to anyone more knowledgable that can help figuring this out