JRascagneres / HA-NationalGrid

Custom component providing information about the UK National Grid power generation
15 stars 1 forks source link

More interconnect links #13

Open SwiftRR opened 1 week ago

SwiftRR commented 1 week ago

Hi, I have been experimenting with this integration and have set up some Apex charts to display information. From one chart, I was alerted to the recent drop in Nuclear generation, done by about 30%. We need the reactors back in these days of little wind!

The Viking interconnect with Denmark isn't listed. Looking at other data, it looks as if the France value is the total from 3 interconnects; also the Ireland value is NI and Eire combined. There are other more minor in connects, e. Manx to IOM and Orkney. There would be a danger of producing a cluttered chart if the France and Ireland interconnects were shown separately.

The Viking link is the big omission. At 10 am on 26/11/2024, it looks like the UK is exporting about 1GW along it.

Do you know if there are plans to extend the interconnect list for this resource?

Thanks

Rob

JRascagneres commented 1 week ago

Hi. We do definitely have Viking Link. This was added prior to Viking Link even becoming live. Its just under the 'Denmark' interconnector at the moment. The ones we have are:

france_mwh: int  # intfr ( IFA ) + intelec ( ElecLink ) + intifa2 ( IFA2 )
ireland_mwh: int  # intirl ( Moyle ) + intew ( East-West )
netherlands_mwh: int  # intned ( Brit Ned )
belgium_mwh: int  # intnem ( Nemo )
norway_mwh: int  # intnsl ( North Sea Link )
denmark_mw: int  # intvkl (Viking Link)

Ones I need to add:

Ireland - Greenlink (expected Jan 2025)

These are the only ones that provide data into the elexon / NG API. I assume Orkney connectors aren't shown as they're considered part of the same grid.

Whats the ask in terms of: France value is the total from 3 interconnects; also the Ireland value is NI and Eire combined. Do you want the interconnector values separated?

SwiftRR commented 1 week ago

Hi, Thanks for the really rapid response. Ireland is there but Viking/Denmark isn't! I am running v0.0.45 which is the most recent version. This is from the readme, listing the feeds and the entities:

image

And this:

image

Whats the ask in terms of: France value is the total from 3 interconnects; also the Ireland value is NI and Eire combined. Do you want the interconnector values separated?

No, I think it would make the chart too cluttered, certainly with three France interconnects. Separate feeds for NI and Eire might be useful but the 'clutter-effect' problems says no to me.

Thanks

Rob

JRascagneres commented 1 week ago

Looks like its missing from docs + that sensor entity. Will get it added there. It has its own sensor though: image

SwiftRR commented 1 week ago

Thanks. I definitely haven't got Viking/Denmark. I look forwards to see the update so that I can upgrade and add Viking.

Rob

JRascagneres commented 1 week ago

You should have the separate sensor at least.

SwiftRR commented 1 week ago

Thanks,

I have Denmark now and have added it to my Apex chart. Does this mean that it was there all the time and I just missed it?

Rob

JRascagneres commented 1 week ago

The separate sensor has been there a long while yeah. Looks like its missing from docs and that sensor that has the attributes so I'll look to add that.

SwiftRR commented 1 week ago

Thanks. That would be really helpful.

I can put together 'history' charts going back in time but I can't work out where to start for forecasts, etc. e.g. You have this as a sample chart in readme:

image

Is there any chance of including yaml for constructing this as an Apex chart Or even just an example for what could be input where you have placed ...

forecast:
    - start_time: ...
      generation: ...
...  
current_value:
forecast:
    - start_time: ...
      transmission_demand: ...
      national_demand: ...
...
requirements:
    - start_time: ...
      end_time: ...
      required_mw: ...
      requirement_type: ...
      despatch_type: ...
      participants_eligible:
        - ...
...

Thanks

Rob

JRascagneres commented 1 week ago

For the wind generation one this is the yaml:

type: custom:apexcharts-card
header:
  show: true
  title: 92 Hour Wind Generation
  show_states: true
  colorize_states: true
graph_span: 92h
apex_config:
  xaxis:
    tooltip:
      enabled: false
now:
  show: true
  color: red
  label: now
span:
  start: day
  offset: "-1d"
series:
  - entity: sensor.national_grid_grid_generation_national_wind_mwh
    name: National Generation
    color: cyan
    opacity: 0.8
    stroke_width: 2
    type: line
    extend_to: false
    group_by:
      func: avg
      duration: 1h
    show:
      legend_value: false
      in_header: raw
  - entity: sensor.national_grid_wind_forecast
    color: green
    opacity: 0.8
    name: Latest Forecast
    data_generator: |
      var now = new Date().getTime();
      var forecastData = entity.attributes.forecast.filter(entry => {
        var startTime = new Date(entry.start_time).getTime();
        if (startTime > start){
          return true
        }
        return false
      });

      return forecastData.map(entry => {
        return [entry.start_time, entry.generation] 
      });
    type: column
    show:
      legend_value: false
      in_header: raw
    fill_raw: last
  - entity: sensor.national_grid_wind_forecast_earliest
    color: red
    opacity: 0.8
    stroke_width: 2
    name: Earliest Forecast
    data_generator: |
      var now = new Date().getTime();
      var forecastData = entity.attributes.forecast.filter(entry => {
        var startTime = new Date(entry.start_time).getTime();
        if (startTime > start){
          return true
        }
        return false
      });

      return forecastData.map(entry => {
        return [entry.start_time, entry.generation] 
      });
    type: line
    show:
      legend_value: false
      in_header: raw
    fill_raw: last
yaxis:
  - min: 0
    max: ~20000
    decimals: 0

However, this is just kinda back in time due to the update frequency.

SwiftRR commented 1 week ago

That is great.

My HA skills are 'adequate' at best but I can adapt this example to generate charts. It will also help me to learn!

I am (reasonably) comfortable with setting up the chart. I would not have had any clue about the data generator sections here.

This is my minimalist Apex chart showing interconnects (now with Denmark added). For some reason, I included Nuclear as well and this nicely shows the drop in nuclear generation over the last few days as plants have got shut down for a couple of week refuelling. It is the first time that I have ever seen nuclear to drop from a steady horizontal line. The chart also shows that France had issues a couple of times in the last week.

Many people visualise interconnects operating from the continent to the UK but they operate a dynamically and bi-directionally. When we had Storm Bert last weekend, it was the UK that supplied many continental countries. These charts are a great way of showing that.

image

Very much appreciated.

Rob

JRascagneres commented 1 week ago

Yeah... They very rarely work the other way though. French nuclear just beats our gas based network any day, market reform needed here but yeah....

The red-ish color is the transfers. Negative is export. Positive is import. image

SwiftRR commented 1 week ago

If you haven't come across it, I am a great fan of an app called Gridwatch. These are two screenshots from the iOS app which I presume is also available for Android. The information is generated in real time.

image

Also worth look at this website https://terravolt.co.uk. That was my source for all the minor interconnects, such as Orkney and IoM and the UK nuclear power sites that are currently down.

Now to try improving my own charting skills .........

Rob

SwiftRR commented 1 week ago

One of the entities in your yaml code isn't being recognised: - entity: sensor.national_grid_grid_generation_national_wind_mwh

In entities, _national_wind_mwh is missing

image

I see no graph at all, just this:

image

HA does save the yaml code but I could only input a truncated entity like this: - entity: sensor.national_grid_grid_generation The resulting chart displays like this. Compare your chart in readme.

image

If I miss out this whole entity section, I see this chart:

image

Does this suggest that this entity is corrupted?

Rob

JRascagneres commented 1 week ago

I might've renamed it. Go to settings --> devices --> national grid --> entities take a look in there. You're looking for something with national wind in the name. Click it, click settings cog and it'll tell you the id

SwiftRR commented 1 week ago

This is what I see:

image

And this is the name of the entity that I used in the yaml as the 'best fit'. This gives the green blurred chart.

I have now checked the name again and have found the entity. This gives the correct chart!

image

What is weird is that I first just copied and pasted in your yaml code and that entity line wasn't being accepted.

Anyway it worked and I will now try to understand the data generator section. A task for another day.

Rob