Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from imthefrizzlefry/summation_received
Browse files Browse the repository at this point in the history
Summation received
  • Loading branch information
ryanwinter authored Apr 16, 2022
2 parents 6c2962d + a5644b1 commit 2ffc887
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
9 changes: 8 additions & 1 deletion custom_components/rainforest_emu_2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def __init__(
self._callbacks = set()

self._power = None

self._summation_delivered = None
self._summation_received = None

self._current_price = None

Expand Down Expand Up @@ -110,7 +112,8 @@ def _process_update(self, type, response) -> None:
self._current_price = response.price_dollars

elif type == 'CurrentSummationDelivered':
self._summation_delivered = response.summation_delivered
self._summation_delivered = response.delivered
self._summation_received = response.received

for callback in self._callbacks:
if (callback[0] == type):
Expand Down Expand Up @@ -151,6 +154,10 @@ def power(self) -> float:
@property
def summation_delivered(self) -> float:
return self._summation_delivered

@property
def summation_received(self) -> float:
return self._summation_received

@property
def current_price(self) -> float:
Expand Down
22 changes: 20 additions & 2 deletions custom_components/rainforest_emu_2/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
Emu2ActivePowerSensor(device),
Emu2CurrentPriceSensor(device),
Emu2CurrentPeriodUsageSensor(device),
Emu2SummationDeliveredSensor(device)
Emu2SummationDeliveredSensor(device),
Emu2SummationReceivedSensor(device)
]
async_add_entities(entities)

Expand Down Expand Up @@ -127,9 +128,26 @@ def __init__(self, device):
self._attr_name = f"{self._device.device_name} Summation Delivered"

self._attr_device_class = SensorDeviceClass.ENERGY
self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
self._attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR

@property
def state(self):
return self._device.summation_delivered

class Emu2SummationReceivedSensor(SensorEntityBase):
should_poll = False

def __init__(self, device):
super().__init__(device, 'CurrentSummationReceived')

self._attr_unique_id = f"{self._device.device_id}_summation_recieved"
self._attr_name = f"{self._device.device_name} Summation Received"

self._attr_device_class = SensorDeviceClass.ENERGY
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
self._attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR

@property
def state(self):
return self._device.summation_received

0 comments on commit 2ffc887

Please sign in to comment.