Skip to content

Commit

Permalink
fix: add dollar native uom to cost sensors (#102)
Browse files Browse the repository at this point in the history
* add dollar native UoM

* Update custom_components/southern_company/sensor.py

---------

Co-authored-by: Luke Lashley <[email protected]>
  • Loading branch information
InTheDaylight14 and Lash-L authored Nov 13, 2024
1 parent 4b22ba1 commit faaa480
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions custom_components/southern_company/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.const import CURRENCY_DOLLAR

from .const import DOMAIN
from .coordinator import SouthernCompanyCoordinator
Expand All @@ -43,6 +44,7 @@ class SouthernCompanyEntityDescription(
device_class=SensorDeviceClass.MONETARY,
suggested_display_precision=2,
value_fn=lambda data: data.dollars_to_date,
native_unit_of_measurement=CURRENCY_DOLLAR,
),
SouthernCompanyEntityDescription(
key="total_kwh_used",
Expand All @@ -57,6 +59,7 @@ class SouthernCompanyEntityDescription(
name="Average daily cost",
device_class=SensorDeviceClass.MONETARY,
value_fn=lambda data: data.average_daily_cost,
native_unit_of_measurement=CURRENCY_DOLLAR,
),
SouthernCompanyEntityDescription(
key="average_daily_usage",
Expand Down Expand Up @@ -87,13 +90,15 @@ class SouthernCompanyEntityDescription(
device_class=SensorDeviceClass.MONETARY,
state_class=SensorStateClass.TOTAL,
value_fn=lambda data: data.projected_bill_amount_low,
native_unit_of_measurement=CURRENCY_DOLLAR,
),
SouthernCompanyEntityDescription(
key="projected_bill_amount_high",
name="Higher projected monthly cost",
device_class=SensorDeviceClass.MONETARY,
state_class=SensorStateClass.TOTAL,
value_fn=lambda data: data.projected_bill_amount_high,
native_unit_of_measurement=CURRENCY_DOLLAR,
),
)

Expand Down

0 comments on commit faaa480

Please sign in to comment.