Impossible to schedule getting JSON results at a certain time?

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

  1. automation launches shell command service, which saves JSON output to file
  2. Use file sensor to import that JSON

It’s like I need a combination of shell command service and command_line sensor.

  • Create a command_line sensor with scan_interval set to a very large number so that it updates very infrequently (currently, there’s no value, like 0, to completely prevent periodic updates).
  • Create an automation that triggers at noon every day and calls the homeassistant.update_entity service to update the command_line sensor.

Homeassistant Services

Indeed, I’d forgotten this was an option. Thank you!

Any other solutions would be welcome as well (from anyone)… including using something besides command_line and curl.

There’s also the RESTful sensor integration.

Example from the documentation:

sensor:
  - platform: rest
    resource: http://IP_ADDRESS:5000/sensor
    username: ha1
    password: test1
    authentication: basic
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json

Now that I have other stuff iron’ed out, I’ve given that a try again… but unless I’m missing something and doing it wrong, it can’t be used for the site I’m trying to access due to certificate nonsense. Anyone know of a way to use a secret ssl key (even the nabu casa one) with the rest sensor?

Error fetching data: … blah blah… (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])”)))