Thanks for the code and dashboard example. I played around with it, rewriting based on rest (vs. sensor | platform | rest). Not necessarily better, just an alternative.
For my purposes (and given the size of the json payload returned by the ERCOT API, 653KB), I reduced the scan interval to once every 15 minutes.
rest:
- scan_interval: 900
resource: "https://www.ercot.com/api/1/services/read/dashboards/daily-prc.json"
sensor:
- name: Ercot Status
unique_id: ercot_status
icon: mdi:transmission-tower
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"
- name: Ercot Grid Operating Reserves
unique_id: ercot_grid_operating_reserves
icon: mdi:transmission-tower
value_template: >
{{ value_json.current_condition.prc_value.replace(",", "") | int(0) }}
- name: Ercot Status Last Updated
unique_id: ercot_status_last_updated
icon: mdi:calendar-clock
value_template: >
{{ value_json.lastUpdated }}
I also made some mods to the dashboard card based on the legend on the ERCOT Grid Conditions Dashboard.
- Updated the max value to 15,000 (based on y axis of the Daily PRC graph)
- Altered the number of segments
- One for each of the condition levels in the ERCOT legend
- Matched the colors to those of the legend
- Adjusted the ranges to mostly match the legend; there aren’t specific MW values documented in the legend so I just went with 1000 increments as it seemed to make sense. The next time we are in an energy reduction period, I’ll be watching to see what conditions are reported for those ranges.
- I added a sensor for ERCOT status last update date and time (from the JSON) and display it at bottom of the card.
type: vertical-stack
cards:
- type: gauge
entity: sensor.ercot_grid_operating_reserves
needle: true
min: 1
max: 15000
segments:
- from: 1
color: '#000000'
- from: 1500
color: '#9d311f'
- from: 2000
color: '#dc3545'
- from: 2500
color: '#fd7e14'
- from: 3500
color: '#ffc107'
- from: 4500
color: '#28a745'
- from: 5500
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') }}"></ha-icon>
</font>
</td>
</tr>
<tr>
<td colspan="2">{{ state_attr('sensor.ercot_status', 'condition_note') }}</td>
</tr>
<tr>
<td colspan="2"><br>Last updated: {{ states('sensor.ercot_status_last_updated') }}</td>
</tr>
</table>
