Jump to content

Home Assistant Tesla Style Power Card


Sc00bs
 Share

Recommended Posts

The built in functionality is only for energy usage (kWh). And gives you an idea what happens throughout the day, incl forecasts and where you drew power from (battery/grid/solar)

The tesla style power card allows you to show current power distribution (W)

So different use cases

I prefer the “power distribution card” above the tesla style power card (could never really figure out the math it tries to do with the sensors, and there is a bug with its rendering)

E6C830FC-55C7-4186-A7EE-D85CB9E85370.jpeg

D88238BD-3851-4B5E-8B90-5443D5280F2F.jpeg

DEB580EA-7744-4D2B-BEEF-3BFB3811898F.jpeg

Link to comment
Share on other sites

14 hours ago, Sc00bs said:

@Tinuva

That is very cool, could you post the code for it perhaps? 

Sure.

First you will need an account with solcast for the forecast. The free account works fine for this, you get 50 api calls I think for free.
Once you have an account, set up a site with your panels total kW capacity and the angle they mounted as well as the direction. Mine is 3900w mounted directly north at around 45 degree angle.

Once done, grab your site as resource_id and the api key.

Then add this to your yaml somewhere (configuration.yaml): Mine is at https://github.com/tinuva/home-assistant-config/blob/master/packages/goodwe_dod.yaml

rest:
- resource: !secret solcast_forecast_resource
  #resource: https://api.solcast.com.au/rooftop_sites/RESOURCE_ID/forecasts?format=json&api_key=API_KEY&hours=72
  scan_interval: '00:30:00' # RATE LIMIT!
  sensor:
  - name: "Solcast Forecast Data"
    force_update: true
    value_template: "{{ value_json.forecasts[0].pv_estimate|round(2) }}"
    json_attributes:
    - forecasts
  - name: "Solcast Forecast 10"
    force_update: true
    value_template: "{{ value_json.forecasts[0].pv_estimate10|round(2) }}"
  - name: "Solcast Forecast 90"
    force_update: true
    value_template: "{{ value_json.forecasts[0].pv_estimate90|round(2) }}"

Then in the the UI, create a card with the following yaml code to get the graph. Replace the sensor.goodwe_ppv with your own actual solar/pv sensor.

type: custom:apexcharts-card
graph_span: 36h
span:
  start: day
  offset: '-6h'
header:
  show: true
  title: Solar Production vs. forecast
  show_states: true
now:
  show: true
  label: now
apex_config:
  legend:
    show: true
series:
  - entity: sensor.goodwe_ppv
    stroke_width: 2
    show:
      extremas: false
    color: '#FFF700'
    name: Actual
    unit: W
    fill_raw: last
    extend_to_end: false
    group_by:
      func: avg
      duration: 30min
  - entity: sensor.solcast_forecast_data
    stroke_width: 2
    show:
      extremas: false
    color: '#3498DB'
    transform: return x * 1000;
    name: Forecast History
    unit: W
    fill_raw: last
    extend_to_end: false
  - entity: sensor.solcast_forecast_10
    stroke_width: 2
    show:
      extremas: false
      in_header: false
    color: '#797D7F'
    transform: return x * 1000;
    name: Forecast 10 History
    unit: W
    fill_raw: last
    extend_to_end: false
    opacity: 0.4
  - entity: sensor.solcast_forecast_90
    stroke_width: 2
    show:
      extremas: false
      in_header: false
    color: '#797D7F'
    transform: return x * 1000;
    name: Forecast 90 History
    unit: W
    fill_raw: last
    extend_to_end: false
    opacity: 0.4
  - entity: sensor.solcast_forecast_data
    stroke_width: 2
    show:
      extremas: false
      in_header: false
    color: '#E74C3C'
    name: Forecast
    type: line
    extend_to_end: false
    unit: W
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
         return [new Date(entry.period_end), entry.pv_estimate*1000];
       });
  - entity: sensor.solcast_forecast_data
    stroke_width: 2
    show:
      extremas: false
      in_header: false
    color: '#797D7F'
    name: Forecast 10
    type: line
    extend_to_end: false
    unit: W
    opacity: 0.4
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
         return [new Date(entry.period_end), entry.pv_estimate10*1000];
       });
  - entity: sensor.solcast_forecast_data
    stroke_width: 2
    show:
      extremas: false
      in_header: false
    color: '#797D7F'
    name: Forecast 90
    type: line
    extend_to_end: false
    unit: W
    opacity: 0.4
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
         return [new Date(entry.period_end), entry.pv_estimate90*1000];
       });

 

All of this is based on testing and ideas from https://community.home-assistant.io/t/rest-api-command-platform-fails-on-post-to-external-url-solcast/143238/141

Link to comment
Share on other sites

Thank you for sharing the graph @Tinuva

I actually use the solar forecast so as to decide whether to switch my pool pump on or not with Node Red. 

I haven't been using it to forecast the actual production number as my batteries are usually full by 12:00 so I have quite a lot of solar power I don't use in summer, but rather just to give me an indication as to how much solar radiation we will have available for the day.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...