I’m experimenting with repeated actions and with httprequests, since the system I’m working on would be checking status on another ESPHome device with an httprequest about once a second. So I have, to test this cycle, a 30 second repeating action and a 60 second repeating action. That’s worked fine:
http_request:
verify_ssl: false
follow_redirects: false
time:
- platform: sntp
on_time:
- seconds: /30
then:
- logger.log: "DEBUG: Logging synced and 30 second repeated action."
- seconds: /60
then:
- logger.log: "DEBUG: Logging synced and 60 second repeated action."
Here’s a screenshot of the logs to show it works fine:
(There are more sections, like the name and friendly name and such, but not, in any way I can see, related to httprequest.)
That showed me that I could do different repeated actions at different intervals. Then I set up a GET request:
http_request:
verify_ssl: false
follow_redirects: false
time:
- platform: sntp
on_time:
- seconds: /30
then:
- logger.log: "DEBUG: Logging synced and 30 second repeated action."
- seconds: /60
then:
- http_request.get:
url: https://esphome.io
headers:
Content-Type: application/json
on_response:
then:
- logger.log:
format: 'Response status: %d, Duration: %u ms'
args:
- response->status_code
- response->duration_ms
I pulled this http_request.get from the httprequest docs. I’ve also replace the url with the local non-secure url for my other ESPHome device, the one that, in the future, this one will be doing a status check every second. All I change in that is the url.
To read from my local system, I’m using http://durin.local/binary_sensor/cnc_system_master
. The system name is durin
. The Binary Sensor is named “CNC System Master” in the name field, and this url gives me json output: {"id":"binary_sensor-cnc_system_master","value":false,"state":"OFF"}
So the url for the local system works and we know the one for the ESPHome site works.
But here are my logs when I try this with the ESPHome site:
So my requests fail because the connection is refused. I’m guessing the unspecified error flag is due to the refused connection.
While doing this test, sometimes I edit the YAML file, save it and compile and install it on the ESP32, and the system is not consistently reachable, either by the ESPHome add-on in HA, or by the website. It’ll go offline and come back, as if that system’s need to use the network connection for the httprequest is somehow blocking me communicating with it to read the logs. I’ve also seen it reboot multiple times during a session without being able to detect the reason. (Yeah, I goofed - should have had screenshots of those logs!)
What do I need to do so my httprequests are not continually refused by my other ESPHome system or the ESPHome website? Is this part of a bigger issue, or just some simple setting I’m not using?