dannerph / homeassistant-solcast

Apache License 2.0
19 stars 3 forks source link

Support multiple rooftops ? #13

Open B-Hartley opened 3 years ago

B-Hartley commented 3 years ago

As SolCast are stopping tuning, they are offering up to two rooftops per accounts to allow for split arrays. How difficult would it be for your component to take two RoofTop IDs, get forecasts for both and add them together?

Or to allow you component to be setup twice with different info, I could then add it together myself.

Thanks, Bruce.

dannerph commented 3 years ago

Hi Bruce, from software architecture view I would go with the second solution, as some of the users might have two completelly different PV system to be observed. I guess the API limit is valid for both RoofTops, that might need some refactoring of the code ...

I am currently busy with a wast colleaction schedule integration, thus do not have time for the solcast integration right now.

B-Hartley commented 3 years ago

No problem. So can two sessions of your integration be added in it’s current form. could I make copies of it and change one to solcast2 or something.

B-Hartley commented 3 years ago

As a temporary fix, I've made a copy of thecustom component under the domain "solcastx" and that way I can run two separate instances and add them together. If anyone else wants to do that and needs a hand, let me know.

nonlinearsugar commented 3 years ago

These instructions were helpful in creating a duplicate component: https://community.home-assistant.io/t/how-can-i-create-a-custom-component-by-copying-another/120455

B-Hartley commented 3 years ago

Yes, that's pretty much what I did. Thanks

monkeydust commented 3 years ago

thanks for this - worked for me

nonlinearsugar commented 3 years ago

This was the template sensor I created to combine the two separate estimates, and the gauge. Does anyone know how to include the "Tomorrow" and "The day after tomorrow" attributes?

#Add to configuration.yaml
sensor:
  - platform: template
    sensors:
      solcast_forecast_total:
        friendly_name: "Solcast Forecast - Total"
        value_template: "{{ states('sensor.solcast_forecast') | float + states('sensor.solcast_forecast_2') | float }}"
        unit_of_measurement: "kWh"
        unique_id: "FpE8m3GmgBsQ"

#Add to Dashboard
type: sensor
entity: sensor.solcast_forecast_total
graph: line
B-Hartley commented 3 years ago

It would be........

sensor:
  - platform: template
    sensors:
      solcast_forecast_tomorrow_total:
        friendly_name: "Solcast Forecast Tomorrow - Total"
        value_template: "{{ state_attr('sensor.solcast_forecast','Tomorrow') | float + state_attr('sensor.solcast_forecast_2','Tomorrow') | float }}"
        unit_of_measurement: "kWh"
        unique_id: "xxxxxxxxxxxxx"
Aereau commented 3 years ago

As a temporary fix, I've made a copy of thecustom component under the domain "solcastx" and that way I can run two separate instances and add them together. If anyone else wants to do that and needs a hand, let me know.

I want to say: great stuff that you already did this. I have an east-west solar configuration on my roof and use two sites for it in Solcast. I would like to add them together and also limit them to the max output of my inverter (I know the Python math for that :))

I have copied the "solcast" custom component folder and renamed it "solcastx", I have also changed the latter manifest.json. I have the following in my configuration.yaml:

solcast: api_key: XXXXX resource_id: EAST api_limit: 20 disable_ssl_check: False disable_automatic_forecast_fetching: False disable_automatic_history_fetching: False

solcastx: api_key: XXXXX resource_id: WEST api_limit: 20 disable_ssl_check: False disable_automatic_forecast_fetching: False disable_automatic_history_fetching: False

However, upon adding an entity in the dashboard, it only sees "sensor.solcast_forecast" entity but not the "x" variants.

What am I doing wrong?

EDIT: In addition to editing manifest.json, I also edited the "domain" in init.py to "solcastx", now it seems that I do have "sensor.solcast_forecast_2"!

B-Hartley commented 3 years ago

There's a bit more to it than that. You have to actually change the code inside the custom component. Take a look at my solcastx custom component.

https://github.com/B-Hartley/bruces_homeassistant_config/tree/main/custom_components/solcastx

Strangely, I'm not acutally using it, as my tuned rooftop is still working and still tuning. So I haven't had the need to switch to the split rooftop setup.