I wonder if anyone can assist on this. I am a complete newbie on HA and not a programmer. I have installed the Solcast integration and it is working. Following the instructions carefully I know that there is a limit of 10 calls to the API and there was an example of an Automation which I have used (see below). The problem is the limit is hit by approx 11:44 every day. I turned on logging and I can see clearly that it is duplicating the call each time it calls the api (at least within a few seconds of each other) hence I assume why I am hitting the buffer. Can anyone help YAML code below
alias: Solcast update
description: “”
trigger:
- platform: template
value_template: >-
{% set nr = as_datetime(state_attr(‘sun.sun’,‘next_rising’)) | as_local %}
{% set ns = as_datetime(state_attr(‘sun.sun’,‘next_setting’)) | as_local
%} {% set api_request_limit = 10 %} {% if nr > ns %}
{% set nr = nr - timedelta(hours = 24) %}
{% endif %} {% set hours_difference = (ns - nr) %} {% set interval_hours =
hours_difference / api_request_limit %} {% set ns = namespace(match =
false) %} {% for i in range(api_request_limit) %}
{% set start_time = nr + (i * interval_hours) %}
{% if ((start_time - timedelta(seconds=30)) <= now()) and (now() <= (start_time + timedelta(seconds=30))) %}
{% set ns.match = true %}
{% endif %}
{% endfor %} {{ ns.match }}
condition: - condition: sun
before: sunset
after: sunrise
action: - delay:
seconds: “{{ range(30, 360)|random|int }}” - data: {}
action: solcast_solar.update_forecasts
mode: single