How many times does a sensor call its API when used multiple times in a script?

I’m making a script that checks sensor.solcast_pv_forecast_forecast_tomorrow multiple times. Since I’ve only got 10 API calls per day I don’t want each call to use one of those API calls. If I check that sensor multiple times does it do an API call to solcast each time, or just the once?

Here’s the code in case it’s helpful. Cheers!

automation:
  - alias: "Solar conditional overnight charge"
    trigger:
      - platform: time
        at: "02:00:00"
    actions:
      - choose:
          - conditions:
              - condition: numeric_state
                entity_id: sensor.solcast_pv_forecast_forecast_tomorrow
                below: 4
            sequence:
              - action: foxess_control.smart_charge
                data:
                  start_time: "02:00:00"
                  end_time: "04:00:00"
                  target_soc: 80
                  replace_conflicts: true
          - conditions:
              - condition: numeric_state
                entity_id: sensor.solcast_pv_forecast_forecast_tomorrow
                below: 6
            sequence:
              - action: foxess_control.smart_charge
                data:
                  start_time: "02:00:00"
                  end_time: "04:00:00"
                  target_soc: 60
                  replace_conflicts: true
          - conditions:
              - condition: numeric_state
                entity_id: sensor.solcast_pv_forecast_forecast_tomorrow
                below: 8
            sequence:
              - action: foxess_control.smart_charge
                data:
                  start_time: "02:00:00"
                  end_time: "04:00:00"
                  target_soc: 40
                  replace_conflicts: true

The likely answer is “0”. Most timing of API calls should be handled by the integration. So, it would be unusual for checking the value stored in HA’s state machine to trigger the API being called.

You didn’t mention which version of Solcast you are using, but it looks like there can be a few Actions that will cause the integration to issue an API call, so you should be aware of those if you have a strict call limit.

Thanks for that. The version is: Solcast PV Forecast by BJReplay Version v4.6.1

You are right, I just checked the integration and it has this:

"If not using auto-update, create an automation that calls the action “solcast_solar.update_forecasts” periodically, while adhering to your Solcast advised maximum total limit (usually ten times total per day for one rooftop site, or with two sites five times per day)

I should have thought to look, but I couldn’t find info about this anywhere I searched. I’m still very new to Home Assistant so thanks for pointing me in the right direction!