JRascagneres / HA-NationalGrid

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

Display returned values in GW? #5

Closed manaesh closed 7 months ago

manaesh commented 7 months ago

Great integration :)

Is there any configuration options or anyway to display the values in GWh?

Thanks

Mike

JRascagneres commented 7 months ago

@manaesh Hi. Thats not something I'm really willing to do as I'd have to duplicate the sensors. If you really want this you can make your own template sensors doing something like the following:

  - sensor:
    - name: "Nuclear GW"
      state_class: measurement
      unit_of_measurement: GW
      icon: mdi:turbine
      state: "{{states('sensor.national_grid_grid_generation_nuclear_mwh') | float(0) / 1000}}"
manaesh commented 7 months ago

@JRascagneres

Many thanks for this! As a relative newbie to Home Assistant (but 20+ years homeseer) - I am still getting my head around HA. Indeed I only installed it to use your integration!

Many thanks for your integration!!!

Cheers

Mike

JRascagneres commented 7 months ago

@manaesh Np :) Lmk if you have any other questions

ando2040 commented 7 months ago

Absolutely awesome integration! Thanks!

Related and not worth opening a separate issue: I'm also trying to define a new sensor in configuration.yaml. The intent is to get a new 3-day demand forecast sensor which will vary with the amount of forecast solar and wind, ie show the balance to be made up with (mostly) non-renewables.

template:
  - sensor:
      - name: "National_Grid_ad_custom_Grid_Generation_Net_Forecast_Three_Day"
        state_class: measurement
        unit_of_measurement: MW
        icon: mdi:turbine
        state: >
          {{ states('sensor.national_grid_grid_demand_three_day_forecast') | float
             - states('sensor.national_grid_wind_forecast_now_to_three_day') | float
             - states('sensor.national_grid_embedded_solar_forecast_three_day') | float }}
        availability: >
          {{ not 'unavailable' in [
               states('sensor.national_grid_grid_demand_three_day_forecast') | float,
               states('sensor.national_grid_wind_forecast_now_to_three_day') | float,
               states('sensor.national_grid_embedded_solar_forecast_three_day') | float ] }}

Template developer tool gives me ValueError: Template error: float got invalid input 'Wind Forecast Now To Three Day' when rendering template 'template: - sensor: - name: "National_Grid_ad_custom_Grid_Generation_Net_Forecast_Three_Day" state_class: measurement unit_of_measurement: MW icon: mdi:turbine state: > {{ states('sensor.national_grid_grid_demand_three_day_forecast') | float - states('sensor.national_grid_wind_forecast_now_to_three_day') | float - states('sensor.national_grid_embedded_solar_forecast_three_day') | float }} availability: > {{ not 'unavailable' in [ states('sensor.national_grid_grid_demand_three_day_forecast') | float, states('sensor.national_grid_wind_forecast_now_to_three_day') | float, states('sensor.national_grid_embedded_solar_forecast_three_day') | float ] }}' but no default was specified

I've checked the sensor names and I'm out of ideas. Maybe data mismatch? national_demand and trying to deduct values called generation? Something else entirely?