Solcast and Home Assistant

Hi all,

I thought I’d start a thread around this service, it’s Home Assistant integration, and what I use it for.

I use Home Assistant and a PV system (Victron based), and found the Solcast service and custom component somebody developed for HA extremely useful:
Solar Forecasting & Solar Irradiance Data (solcast.com)
Solcast discussion on Home Assistant Community (home-assistant.io)

It (Solcast’s website + the customer component) allows you to:

  1. register a free residential service with your system details (location, AC/DC system side, angles etc.)
  2. submit readings from your system to “tune” their prediction model towards your actual system
  3. request an estimated PV yield for the rest of the day (up to 10 or 20 times a day for residential accounts), taking into account estimated cloud coverage, location, time of day, time of the year etc.

So I use it to boost my geyser’s temperature:

  1. when my batteries reach 100%, ask the Solcast sensor for the estimated PV yield left (for my system, for today)
  2. when there’s enough, run the geyser for 15 mins. It is a 4kw element, so it uses 1 kWh.
  3. repeat until the geyser is super hot (70 degrees in my case) or there’s not enough PV yield left (3 kWh in my case) – that way I get to “store” more of my PV energy and keep the geyser hot for subsequent cloudy days.

Of course, you do not need to use it with a geyser (I had to get the temperature of my geyser into HA too). You can use it to run a borehole, run an aircon, run a crypto miner etc. using your “free” energy.

Here’s my forecast for the rest of the day (and tomorrow and the day after):

And here’s the Solcast website’s own forecast graph, and how I “tune” their model to my system:

3 Likes

Nice.
Are you doing the logic in Node Red?

Nope, all in Home Assistant native.

I’ve never felt the need to bring in Node Red into the equation too.

Cool, I must look into how you make REST calls from HA

There’s a RESTful command which I use to send back the measurements to Home Assistant to tune the system: RESTful Command - Home Assistant (home-assistant.io)

Mine looks like this:

rest_command:
  solcast_tune:
    url: !secret solcast_tune_url_auth 
    method: POST
    headers:
      Content-Type: application/json
    payload: "{{states('sensor.solcast_post')}}" 

The sensor.solcast_post contains the kW output of my system, averaged over the last 5 minutes.
The URL is based on what Solcast’s API needs, but basically something like:
solcast_tune_url_auth: 'https://api.solcast.com.au/rooftop_sites/<rooftop ID>/measurements?api_key=<api_key>'

Then to send the REST command I basically call the service generated:

  action:
    service: rest_command.solcast_tune
2 Likes

Questions:

  • How often do you call that?
  • Easiest way to get previous 5 min kW? (History?)
  • I assume it’s much the same for the other API call to get projected PV? (ie, the GET call to make decisions based off of)

I use the Solcast custom component to request the history and the forecast. It isn’t the greatest – definitely room for improvement – but it works. Getting the rest of the day’s forecast is basically what I need.

In terms of sending the data back, I submit every 5 mins during daylight, as long as I know I’m getting max PV use. In my case, this is if I am in Bulk mode and the batteries are not yet charged – I know my batteries pull most of the current from the panels. Once I reach absorb or float I stop pushing updates, because I don’t want to “train” Solcast that I have less PV than what they predict. This is why my “actuals” on Solcast falls mid-day.

I have a sensor which averages the PV yield over the last 5 minutes:

##5 minute average for production
  - platform: statistics
    entity_id: sensor.victron_pv_power
    name: pv_stats
    max_age:
      minutes: 5

Then I have this automation which actually submits (i.e. calls the service created by the restful component):

- alias: solcast-upload
  trigger:
    platform: time_pattern
    minutes: /5
  condition:
    condition: and
    conditions:
    - condition: sun
      before: sunset
      before_offset: +00:30:00
    - condition: sun
      after: sunrise
      after_offset: -00:30:00
    - condition: state
      entity_id: switch.force_charge
      state: 'off'
    - condition: state
      entity_id: sensor.victron_inverter_state
      state: Bulk
      for:
        minutes: 5
  action:
    service: rest_command.solcast_tune
2 Likes

Thank you very, very much @ebendl for the detailed info above. I just today managed to get it working, after half heartedly messing with it the last few weeks. Now to let it run for a bit and wait for the tuning to start working.

Took about 10 days if I remember correctly!

Thanks folks, I’ve almost got it working.

Just need to understand how to get from pv_stats to sensor.solcast_post.
I assume that’s building the json body that goes to the measurements endpoint, but I’m unclear on how to do that exactly.

Edit: Nevermind, found it here: https://community.home-assistant.io/t/rest-api-command-platform-fails-on-post-to-external-url-solcast/143238/27

you’re right, I never actually posted that part!

Here you go – it is a template sensor that reads the 5 min average and then formats the JSON string:

##Template sensor for POST string
  - platform: template
    sensors:
      solcast_post:
        entity_id:
          - sensor.date_time_iso
          - sensor.pv_stats
        value_template: >
          {{ '{"measurement": {"period_end": "' ~ as_timestamp(states.sensor.date_time_iso.state)|timestamp_custom ('%Y-%m-%dT%H:%M:%SZ', false) ~ '", "period": "PT5M","total_power": ' ~ state_attr('sensor.pv_stats', 'mean')|float / 1000 ~ '}}' }}

Thanks, that actually also includes the /1000, which is needed if your modbus is reporting W, not kW (had to break out Postman to work out why nothing was going through…)

Hi All

Been following this a bit - long shot but does anyone have a Node-Red flow working with Solcast? I have tried the one on discourse.nodered.org but with no luck.

Thanks
Mark

Question: should the “discharging” state not also be included (as well as “bulk”), since the panels are also working as hard as they can in that state?
I find that ensures you submit measurements at less solar-optimal times, which will give a better tuning picture.
Unless I’m missing something?

Edit: Nevermind, I see that what VRM reports as “Discharging”, the modbus still reports as “Bulk”, so it’s all good.

Hi @MongooseMan

I haven’t really thought of another way to pick up max PV production - other than trying to actually use more PV throughout the day :slight_smile:

Batteries are great because they take whatever they can.

That being said I get good correlation with the couple of hours I do post so it serves it purpose in my case!

Sadface, no more tuning:
image

yeah, that is a pity.

Here’s the article in the link: PV Tuning Discontinued | Solcast - Help Center

For users of the Rooftop PV sites product, we will be decommissioning this endpoint for future commercial use. However, we will retain it for use by hobbyists for modelling and forecasting the power output of their home PV systems. Since we will be removing the PV Tuning capability, we are now providing hobbyists with the ability to add a second PV site at their home location, in order to handle split-array set-ups.

If you would like to activate a second PV site for your home, simply contact us using the ‘chat bubble’ at the bottom right of your screen with your request. Be sure to include the email address you are using for your API Toolkit account!

So am I correct that they’re removing the commercial Rooftop PV option altogether, except for the free hobby accounts? And in those instances we can get 2 sites?

Mmm, fine I guess. I wonder what will happen with all the tuning data that I’ve already sent through. It was definitely way more accurate than the original values I had on the website.

Yeah, not sure.
Would have been nice to tune it over winter, since I imagine that’s where it’ll pay dividends to be accurate.

Some discussion here on the HA community forums too: REST API command/platform fails on POST to external URL (solcast) - Configuration - Home Assistant Community (home-assistant.io)

Is anyone keen to share your Node Red flow for SolCast… not worried about tuning but keen to see how you guys do the basic forecast…

Thanks