Hi,
I am running HA OS on a pi4
I have various other command_line integrations that call a curl:
If I call this from the HA command line, it works fine
In the logs, it often does not - but frustratingly sometimes it works fine
Logger: homeassistant.components.command_line.switch
Source: components/command_line/switch.py:133
Integration: command_line (documentation, issues)
First occurred: 07:15:15 (2 occurrences)
Last logged: 17:15:15
Command failed: curl --retry 5 http://various_urls
Any ideas? I can see this question has come up in the past, but not sure it was ever resolved…
le_top
June 15, 2022, 4:56pm
2
I suppose that curl is not installed in the “homeassitant container”.
You could turn to pyscript, appdaemon, netdaemon to run in a container where you can install extra packets including curl.
I used AppDaemon recently to install all the stuff needed to run python using selenium with chromium in the Alpine Linux based container.
Thanks
this post:
Just follow the documentation on installing on a generic Linux distro. I’ve linked the documentation.
Install Raspbian.
Install prerequisites according to the official documentation and run the script, again, following the official documentation.
When people go off and create tutorials, they become outdated and worthless. Just follow the official documentation and it will work.
Suggests that curl likely is available
However, this post looks like I can debug the problem:
I’ve noticed there’s a significant number of posts looking for help on this topic and the posters all seem to struggle with a few common issues. I realized I’ve been almost copying and pasting my responses on these topics so it seemed like a good case for a community guide.
What will this cover
This guide will walk through the process of getting a command which ssh’s into another machine to get some simple data ready to be included in a command line sensor . To keep it simple I’ll use the same …
le_top
June 15, 2022, 8:23pm
4
I did a quick implementation of how this can work with AppDaemon:
call_script.py
import sys
import subprocess as s
import adbase as ad
import hassapi as hass
class CallScript(hass.Hass):
def initialize(self):
event_name = "call_script"
This file has been truncated. show original
script.yaml
---
script1:
module: call_script
class: CallScript
script: /bin/ls
outfile: /config/appdaemon/apps/test.log
errfile: /config/appdaemon/apps/testerr.log
args:
- -lRt
- /config
This file has been truncated. show original
It’s a generic AppDaemon module that you can use to call pretty much any command available in AppDaemons container. The script.yaml
file shows two examples with an ls
on different directories and outputting to different logs.
With the following AppDaemon configuration you should have access to curl
.
init_commands: []
python_packages: []
system_packages:
- curl
Note: you can add an ‘event’ parameter to provide an event name such as ‘call_script1’ and then add an automation:
alias: DemoScript1
description: ''
trigger:
- platform: time_pattern
minutes: '45'
hours: '1'
condition: []
action:
- event: call_script1
event_data: {}
mode: single
1 Like
Thanks!
I tried the details here:
I’ve noticed there’s a significant number of posts looking for help on this topic and the posters all seem to struggle with a few common issues. I realized I’ve been almost copying and pasting my responses on these topics so it seemed like a good case for a community guide.
What will this cover
This guide will walk through the process of getting a command which ssh’s into another machine to get some simple data ready to be included in a command line sensor . To keep it simple I’ll use the same …
This seemed to confirm that curl should work…but I will definitely give your idea a look as well - thanks very much!