Curl performance question

I’ve been doing housekeeping and working on streamlining/combining inefficient code I wrote when I was new to HA.

I use curl quite a bit to get sensor data from text files stored on other computers on my network. I’m interested in whatever method uses the fewest resources on my slow RPi3B.

Is there any performance difference between these two methods of getting the contents of a text file?

  - platform: command_line
    command: "curl ''"
    scan_interval: 300
    name: Airpods case
    unit_of_measurement: '%'
  - platform: command_line
    command: python3 -c "import requests; print(requests.get('').text)"
    name: Airpods case 


curl will be more lightweight than loading the whole Python interpreter. Just tried it on my Banana Pi: curl averages about 0.2s to complete a request for a file off the printer on my LAN, Python takes 2.8s so 14× slower…

1 Like

That’s great, thanks!