At a high level, I’m trying to do a POST using a SSL cert and capture the JSON result. In the spirit of being efficient, I’ve gone looking for how to schedule such a thing once per day (results are available at noon) rather than blindly polling it 2 or 3 times a day.
First off, the only way I know to do a POST using a specific SSL cert is via curl (or external python script). I’d love to know of other options (regardless if it helps with the solution).
Here is a simplified example of what I’m doing:
- platform: command_line
name: NameName
value_template: ''{{ value_json.returned_value }}"
scan_interval: #### actually only want to do this at noon each day
command: >-
/usr/bin/curl https://URL/
--lots-o-arguments
--data \' {
\"date\" : \"{{ states("sensor.yesterday_usa") }} \"
} \'
I could probably launch the curl command from cron rather than HA (although getting yesterday’s date inside the JSON might be a bit annoying… maybe use python rather than curl), but I’m trying to use this as an opportunity to learn HA better.
The best I can come up with is
- automation launches shell command service, which saves JSON output to file
- Use file sensor to import that JSON
It’s like I need a combination of shell command service and command_line sensor.