Texas Electricity Grid Monitor

Awesome! Works great. Thanks very much!

Here’s a sensor for the current wholesale price per kilowatt. I needed something that would alert me so that I would know to dump the Powerwalls to the grid. Normally the wholesale price is around $0.02. Yesterday it hit nearly $5.00. It is one of my first sensors and some of my first Jija, so feedback and tips welcome. It basically loops through the JSON response and delivers the wholesale average that corresponds to the highest timestamp in the record.


- platform: rest
    scan_interval: 900
    unit_of_measurement: "$"
    unique_id: ercot_realtime_system_wide_prices
    icon: mdi:transmission-tower
    name: "ERCOT Realtime Wholesale per kWh"
    resource: "https://www.ercot.com/api/1/services/read/dashboards/systemWidePrices.json"
    value_template: >-
      {% set nsmi = namespace(max_interval = 0) %}
      {% set nshba = namespace(hbBusAvg = 0) %}
      {% for data in value_json.rtSppData %}
        {% if data['interval'] > nsmi.max_interval %}
          {% set nsmi.max_interval = data['interval'] %}
          {% set nshba.hbBusAvg = data['hbBusAvg'] %}
        {% endif %}
      {% endfor %}
      {{nshba.hbBusAvg/1000}}

I’m currently getting “Entity not available: sensor.grid_operating_reserves” Does yours still work? Do you mind providing your sensor configuration?

This post from above should be the needed config.

Thank you so much for this info. I was struggling with the github config. I was able to get it to collect data but the Current Reading sensor didn’t work in the Energy Dashboard. Your changes work great!

I did have to remove the smartmetertexas: value at the top of the smt package and also added a sensor for the hourly energy reading.

packages/smartmetertexas.yaml

  mqtt:
    sensor:
      - state_topic: "smt/reading"
        unit_of_measurement: "kWh"
        name: Smart Meter Texas Current Reading
        unique_id: smart_meter_texas_current_reading
        device_class: energy

  sensor:
    - platform: template
      sensors:

        smtexas_energy_last_hour:
          friendly_name: Hourly Energy
          unit_of_measurement: 'kWh'
          value_template: "{{ state_attr('sensor.hourly_energy','last_period') }}"
          icon_template: mdi:counter

  utility_meter:
    hourly_energy:
      source: sensor.smart_meter_texas_current_reading
      name: Hourly Energy
      cycle: hourly
    daily_energy:
      source: sensor.smart_meter_texas_current_reading
      name: Daily Energy
      cycle: daily
    monthly_energy:
      source: sensor.smart_meter_texas_current_reading
      name: Monthly Energy
      cycle: monthly

  input_number:
    smtexas_energy_cost:
      icon: mdi:currency-usd
      name: Electricity Cost
      mode: box
      min: 0
      max: 2.50
      step: .001
      unit_of_measurement: "$/kWh"

This post might be redundant but hopefully this helps another following mnewm4’s great templates.

I did some tinkering and reading through this thread and had to make changes to get this working for me as of 8 September 2023. I am running:

  • Home Assistant 2023.9.0
  • Supervisor 2023.08.3
  • Operating System 10.5
  • Frontend 20230906.1 - latest

I added this into my configuration.yaml to add the sensors ‘sensor.ercot_status’ (for the text conditions in the later Markdown card) and ‘sensor.ercot_reserves’ (for the needle gauge card) into the “sensor:” section of the file.

configuration.yaml:

sensor:
# there may be tons of other sensors in here already
  - platform: rest
    scan_interval: 300
    unique_id: ercot_status
    icon: mdi:transmission-tower
    name: Ercot Status
    resource: "https://www.ercot.com/api/1/services/read/dashboards/daily-prc.json"
    value_template: "{{value_json.current_condition.state}}"
    json_attributes_path: "$.current_condition"
    json_attributes:
      - energy_level_value
      - title
      - condition_note
      - eea_level
      - prc_value
      - datetime
  - platform: template
    sensors:
      ercot_reserves:
        unique_id: ercot_grid_operating_reserves
        friendly_name: "Ercot Operating Reserves"
        unit_of_measurement: MW
        icon_template: mdi:transmission-tower
        value_template: >-
          {{states.sensor.ercot_status.attributes.prc_value.replace(",", "") }}

I then added these into a default Lovelace card of “Vertical Stack” with the following yaml code:

type: vertical-stack
cards:
  - type: gauge
    entity: sensor.ercot_reserves
    needle: true
    min: 1
    max: 7000
    segments:
      - from: 1
        color: '#000000'
      - from: 1000
        color: '#FF0000'
      - from: 1750
        color: '#FFA500'
      - from: 2300
        color: '#FFFF00'
      - from: 2900
        color: '#008000'
    name: Electricity Grid Operating Reserves
    unit: MW
  - type: markdown
    content: >-
      <table width="100%">
      <tr>
      <td><h2> {{ state_attr('sensor.ercot_status','title') }} </h2> </td>
      <td align='right'><font color='#44739e'> <ha-icon icon="{{ state_attr( 'sensor.ercot_status', 'icon' ) }}"></font></ha-icon></td>
      </tr>
      <tr>
      <td colspan="2"> {{ state_attr( 'sensor.ercot_status', 'condition_note' )
      }} </td>
      </tr>
      </table>

And that results in this Vertical Stack card:

If the Markdown card doesn’t work on a copy and paste, then double check that the copy paste operation from your browser over to your card yaml input didn’t insert and create extra line breaks. For example, the “<td align… </ha-icon></td>” should be on one line and “<td colspan… </td>” should be on one line inside the card’s yaml.

Best of luck!

2 Likes

Just validating, @selfjc’s post above worked “out of the box” for me in January 2024. Thanks for the research and effort all!