JRascagneres / HA-NationalGrid

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

Integrating DFS dates #3

Closed garethcook closed 8 months ago

garethcook commented 8 months ago

Feature request: add DFS support please

https://jamiej.co.uk/blog/updated-sensor-yam-for-2023-24-adding-national-grids-dfs-dates-to-home-assistant/

JRascagneres commented 8 months ago

I'll look into this, should be easy enough

JRascagneres commented 8 months ago

I can implement this data - https://www.nationalgrideso.com/data-portal/demand-flexibility-service/dfs_industry_notification Will work on it over weekend.

deltamelter commented 8 months ago

You can also use the same API as you use for the other ESO data. Found this one which grabs the requirements https://api.nationalgrideso.com/api/3/action/datastore_search?resource_id=7914dd99-fe1c-41ba-9989-5784531c58bb and the accepted bids... https://api.nationalgrideso.com/api/3/action/datastore_search?resource_id=ed7019b0-32b7-425c-a2fb-5ba9e32733fb

JRascagneres commented 8 months ago

Yup

JRascagneres commented 8 months ago

I think I'll opt for integrating just this one:

https://api.nationalgrideso.com/api/3/action/datastore_search?resource_id=7914dd99-fe1c-41ba-9989-5784531c58bb

Not sure how best to do it to avoid hitting any kind of capacity limits on the data.

What are you after? Just any 'upcoming' sessions? and presumably who's eligible for each so you can filter down to your provider? @garethcook

garethcook commented 8 months ago

I think I'll opt for integrating just this one:


https://api.nationalgrideso.com/api/3/action/datastore_search?resource_id=7914dd99-fe1c-41ba-9989-5784531c58bb

Not sure how best to do it to avoid hitting any kind of capacity limits on the data.

What are you after? Just any 'upcoming' sessions? and presumably who's eligible for each so you can filter down to your provider?

@garethcook

Upcoming sessions, yes. As of now they are not that frequent but do get released on the day. We'd need to look at the historical data but I recall it being mid morning. Eligibility could be useful

garethcook commented 8 months ago

Here's the historical notification data https://www.nationalgrideso.com/data-portal/demand-flexibility-service/dfs_industry_notification

The times vary from 08:00 to 15:00. First thoughts are at 9am, midday and 3pm (or perhaps offset by 30 mins, 9.30, 12.30 and 15.30). Is there a push service to avoid pulling from via API?

JRascagneres commented 8 months ago

I'll need to pull from the API. I can be fairly lazy and do it in my current schedule which is 5 minutes.

JRascagneres commented 8 months ago

@garethcook I've added DFS requirements. It uses this data - https://www.nationalgrideso.com/data-portal/demand-flexibility-service/dfs_service_requirements

It shows from, to, requirement, requirement type, despatch type and eligible participants.

Currently its in the 'beta' version I'm working on that adds requests from the other issue too. - https://github.com/JRascagneres/HA-NationalGrid/releases/tag/v0.0.35

Take a peek at it.

JRascagneres commented 8 months ago

Let me know if this meets what you needed :) @garethcook

JRascagneres commented 8 months ago

There was an issue - Fixed it in latest https://github.com/JRascagneres/HA-NationalGrid/releases/tag/v0.0.37

garethcook commented 8 months ago

Superb. Now - how on earth do I use it :-) I'm on Octopus, I see many different sections for Octopus, and I'm not sure how you determine to which one belongs. Ending up with a datetime entity would be ideal, that change can be used in automations.

JRascagneres commented 8 months ago

You'd have to write a template sensor or something to query it to find the item that includes octopus as a supplier.

If you're just on octopus and you just want the saving session time I'd use the octopus integration.

JRascagneres commented 8 months ago

Like I say I recommend using the octopus integration but you can play around with template work. Like this filters the results down to a list of DFS events that have Octopus eligible and are in the future:

{{ state_attr('sensor.national_grid_dfs_requirements', 'requirements') | selectattr('participants_eligible', 'search', 'OCTOPUS ENERGY LIMITED') | list | rejectattr('end_time', 'lt', now()) | list }}
garethcook commented 8 months ago

Like I say I recommend using the octopus integration but you can play around with template work. Like this filters the results down to a list of DFS events that have Octopus eligible and are in the future:

{{ state_attr('sensor.national_grid_dfs_requirements', 'requirements') | selectattr('participants_eligible', 'search', 'OCTOPUS ENERGY LIMITED') | list | rejectattr('end_time', 'lt', now()) | list }}

Excellent, thankyou!

garethcook commented 7 months ago

I implemented your script above, and usually the sensor just displays [] on the dashboard. Until a couple of days ago where the DFS slots became active, where it changed to unknown.

Is there merit in pulling some log data to understand if it's the script or otherwise to establish the correct values? Ta

JRascagneres commented 7 months ago

Yeah [] would be expected here, what I gave is not a full implementation. I'd highly recommend using the octopus integration in this case; getting exactly what you want without full understanding isn't super easy and I can't easily make what you want work for all providers.

garethcook commented 7 months ago

I have used the Octopus integration for a while, but it won't give you advance notice of slots where this DFS linkage would allowing for some automation ahead of time, and earlier notification before Octopus. I'll take another look at your code, thanks.

deltamelter commented 7 months ago

My "Savey Davey" automation triggered today at 9am an notified me of req change but the notification automation didn't like the second condition based on the above template test Weird because it works in the template testbed and if I change state manually to test gave me... "Test session today between 1700-1800"

deltamelter commented 7 months ago

Screenshot_20240208_123004_Opera

garethcook commented 7 months ago

Screenshot_20240208_123004_Opera

Can I have your code please? :-) Thanks

deltamelter commented 6 months ago

Can I have your code please? :-) Thanks

I use a value template condition based on the code from JRascagneres above: image

garethcook commented 6 months ago

Can I have your code please? :-) Thanks

I use a value template condition based on the code from JRascagneres above: image

Looks way better than my attempt, would you be OK sharing the yaml, please?