Add griddy integration (#32591)
* Add griddy integration * Griddy is a wholesale power provider in Texas * Supports all four load zones in Texas * Provides real time power price which is useful for automations to handle demand response * Update homeassistant/components/griddy/sensor.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/griddy/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Add ability request updated via entity update service. * Improve error message about already configured * Remove DEVICE_CLASS_POWER since we do not have a device class for cost * remove setdefault that was left from previous refactor * More detail on data naming * Bump translation for testing * git add the config flow tests * s/PlatformNotReady/ConfigEntryNotReady/ * Review items * git add the other missing file * Patch griddypower * reduce * adjust target Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
21cff003f8
commit
908ae23738
15 changed files with 1012 additions and 0 deletions
76
homeassistant/components/griddy/sensor.py
Normal file
76
homeassistant/components/griddy/sensor.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
"""Support for August sensors."""
|
||||
import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
from .const import CONF_LOADZONE, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the August sensors."""
|
||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
settlement_point = config_entry.data[CONF_LOADZONE]
|
||||
|
||||
async_add_entities([GriddyPriceSensor(settlement_point, coordinator)], True)
|
||||
|
||||
|
||||
class GriddyPriceSensor(Entity):
|
||||
"""Representation of an August sensor."""
|
||||
|
||||
def __init__(self, settlement_point, coordinator):
|
||||
"""Initialize the sensor."""
|
||||
self._coordinator = coordinator
|
||||
self._settlement_point = settlement_point
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
return "¢/kWh"
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Device Name."""
|
||||
return f"{self._settlement_point} Price Now"
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Device Ice."""
|
||||
return "mdi:currency-usd"
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Device Uniqueid."""
|
||||
return f"{self._settlement_point}_price_now"
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if entity is available."""
|
||||
return self._coordinator.last_update_success
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Get the current price."""
|
||||
return round(float(self._coordinator.data.now.price_cents_kwh), 4)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Return False, updates are controlled via coordinator."""
|
||||
return False
|
||||
|
||||
async def async_update(self):
|
||||
"""Update the entity.
|
||||
|
||||
Only used by the generic entity update service.
|
||||
"""
|
||||
await self._coordinator.async_request_refresh()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Subscribe to updates."""
|
||||
self._coordinator.async_add_listener(self.async_write_ha_state)
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""Undo subscription."""
|
||||
self._coordinator.async_remove_listener(self.async_write_ha_state)
|
Loading…
Add table
Add a link
Reference in a new issue