Skip to content

oziee/ha-solcast-solar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Before submitting an issue, search the issues and discussion forum to see if this has already been ask and answered in the past. The following usually fixes most users problems...

  • make sure the API key you enter is the API key and not the rooftop id
  • make sure the solcast toolkit area is working
  • READ THE LOG OUTPUT, this gives some good info as to whats happening or a problem
  • make sure your not out of API calls
  • if all that fails run the service to delete the solcast data file (or manually delete it from HA/config/solcast.json and restart HA)

HA Solcast PV Solar Forecast Integration

Home Assistant(https://www.home-assistant.io) Integration Component

This custom component integrates the Solcast Hobby PV Forecast API into Home Assistant.

hacs_badge

⚠️ Solcast have altered their API limits for new account creators

Solcast now only offer new account creators 10 api calls per day (used to be 50). 
Old account users still have 50 api calls

The integration now no longer includes auto api polling. Users now need to create their own automations
to call the update solcast service to poll for new data. Keep in mind your API poll limit.

Solcast Requirements:

Sign up for an API key (https://solcast.com/)

Solcast may take up to 24hrs to create the account

Copy the API Key for use with this integration (See Configuration below).

Installation

HACS (recommended)

Using HACS. More info here

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Manually in HACS
Follow the link here
Use the custom repo link https://github.com/oziee/ha-solcast-solar
Select the category type integration
Then once it's there (still in HACS) click the INSTALL button
Then go to the HA Devices and Services and add a new Solcast Integration

Manualy

You probably do not want to do this! Use the HACS method above unless you know what you are doing and have a good reason as to why you are installing manually

  1. Using the tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml)
  2. If you do not have a custom_components directory there, you need to create it
  3. In the custom_components directory create a new folder called solcast_solar
  4. Download all the files from the custom_components/solcast_solar/ directory in this repository
  5. Place the files you downloaded in the new directory you created
  6. Restart HA to load the new integration
  7. See Configuration below

Configuration

  1. Click Here to directly add a Solcast Solar integration or
    a. In Home Assistant, go to Settings -> Integrations
    b. Click + Add Integrations and select Solcast PV Forecast
  2. Enter you Solcast API Key
  3. Click Submit
  • Create your own automation to call the service solcast_solar.update_forecasts when you like it to call

  • Options can be changed for existing Solcast PV Forecast integration in Home Assistant Integrations by selecting Configure (cog wheel)

  • If you have more than one Solcast account because you have more than 2 rooftop setups, enter both account API keys seperated by a comma xxxxxxxx-xxxxx-xxxx,yyyyyyyy-yyyyy-yyyy (this does go against Solcast T&C's having more than one account)

  • This is your API Key not your rooftop id created in Solcast. You can find your API key here api key

Dampening Configuration

New in v4.0.8 is the option to configure hourly dampening values

Here you can change the dampening factor value for any hour. Values from 0.0 - 1.0 are valid. Setting 0.95 will dampen each Solcast forecast data value by 5%. This is reflected in the sensor values and attributes and also in the graphical energy dash board

Services

There are 3 services for this integration that you can use in automations (Configuration)

Service Action
solcast_solar.update_forecasts Updates the future forecast data only
solcast_solar.clear_all_solcast_data Deletes the solcast.json cached file
solcast_solar.query_forecast_data Returns a list of forecast data using a datetime range start - end
solcast_solar.set_dampening Updates the hourly dampening factors

Basic HA Automation to manual poll Solcast API data

Create a new HA automation and setup your prefered triggers to manually poll for new data
These are examples.. alter these or create your own to fit your own needs

alias: Solcast_update
description: New API call Solcast
trigger:
 - platform: time_pattern
   hours: /4
condition:
 - condition: sun
   before: sunset
   after: sunrise
action:
 - service: solcast_solar.update_forecasts
   data: {}
mode: single

or

alias: Solcast update
description: ""
trigger:
  - platform: time
    at: "4:00:00"
  - platform: time
    at: "10:00:00"
  - platform: time
    at: "16:00:00"
condition: []
action:
  - service: solcast_solar.update_forecasts
    data: {}
mode: single

To make the most of the available API calls, you can call the API in an interval calculated by the number of daytime hours by the number of total API calls a day:

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:
  - service: solcast_solar.update_forecasts
    data: {}
mode: single

Note If you have two arrays on your roof then 2 api calls will be made for each update, effectively reducing the number of updates to 5 per day. For this case, change to: api_request_limit = 5

Set up HA Energy Dashboard settings

Go to the HA>Settings>Dashboards>Energy Click the edit the Solar Production item you have created.

Note If you do not have a solar sensor in your system then this integration will not work. The graph, and adding the forecast integration rely on there being a sensor setup to be added here

Click the Forecast option button and select the Solcast Solar option.. Click SAVE.. HA will do all the rest for you

HA Views:

HA Energy Tab

Sensors

Name Type Attributes Unit Description
Today number Y kWh Total forecast solar production for today
Tomorrow number Y kWh Total forecast solar production for day + 1 (tomorrow)
D3 number Y kWh Total forecast solar production for day + 2 (day 3)
D4 number Y kWh Total forecast solar production for day + 3 (day 4)
D5 number Y kWh Total forecast solar production for day + 4 (day 5)
D6 number Y kWh Total forecast solar production for day + 5 (day 6)
D7 number Y kWh Total forecast solar production for day + 6 (day 7)
This Hour number N Wh Forecasted solar production current hour
Next Hour number N Wh Forecasted solar production next hour
Remaining Today number N kWh Predicted remaining solar production today
Peak Forecast Today number N W Highest predicted production within an hour period today
Peak Time Today date/time N Hour of max forecasted production of solar today
Peak Forecast Tomorrow number N W Highest predicted production within an hour period tomorrow
Peak Time Tomorrow date/time N Hour of max forecasted production of solar tomorrow
Power Now number N W Power forecast during the current 0-30 / 30-59 min hour period
Power Next 30 Mins number N W Power forecast for the next 30 min block period
Power Next Hour number N W Power forecast for the next block 60 min from now

Configuration

Name Type Attributes Unit Description
Rooftop name number Y kWh Total forecast for rooftop today (attributes contain the solcast rooftop setup)

Diagnostic

Name Type Attributes Unit Description
API Last Polled date/time N Date/time when the API data was polled
API Limit number N integer Total times the API can been called in a 24 hour period1
API used number N integer Total times the API has been called today (API counter resets to zero at midnight UTC)1

Credits

Modified from the great works of

  • @rany2 - ranygh@riseup.net
  • dannerph/homeassistant-solcast
  • cjtapper/solcast-py
  • home-assistant-libs/forecast_solar

Footnotes

  1. API usage information is directly read from Solcast 2