Skip to content

Commit b907f70

Browse files
authored
Merge pull request #179 from CharlesGillanders/additonal-sensors
Add tree count and co2 reduction sensors
2 parents 03db9b8 + 404acb8 commit b907f70

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

custom_components/alphaess/coordinator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ async def _async_update_data(self):
160160
inverterdata["Total Load"] = await safe_get(_sumdata, "eload")
161161
inverterdata["Total Income"] = await safe_get(_sumdata, "totalIncome")
162162
inverterdata["Total Generation"] = await safe_get(_sumdata, "epvtotal")
163+
inverterdata["Trees Planted"] = await safe_get(_sumdata, "treeNum")
164+
inverterdata["Co2 Reduction"] = await safe_get(_sumdata, "carbonNum")
163165

164166
self_data = {
165167
"Self Consumption": await safe_get(_sumdata, "eselfConsumption"),

custom_components/alphaess/enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,5 @@ class AlphaESSNames(str, Enum):
7070
evcurrentsetting = "Household current setup"
7171
startcharging = "Start Charging"
7272
stopcharging = "Stop Charging"
73+
treePlanted = "Trees Planted"
74+
carbonReduction = "Co2 Reduction"

custom_components/alphaess/sensorlist.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SensorDeviceClass,
55
SensorStateClass,
66
)
7-
from homeassistant.const import UnitOfEnergy, PERCENTAGE, UnitOfPower, CURRENCY_DOLLAR, EntityCategory
7+
from homeassistant.const import UnitOfEnergy, PERCENTAGE, UnitOfPower, CURRENCY_DOLLAR, EntityCategory, UnitOfMass
88

99
from .entity import AlphaESSSensorDescription, AlphaESSButtonDescription, AlphaESSNumberDescription
1010
from .enums import AlphaESSNames
@@ -364,8 +364,22 @@
364364
device_class=SensorDeviceClass.POWER,
365365
state_class=SensorStateClass.MEASUREMENT,
366366
icon="mdi:flash",
367+
),
368+
AlphaESSSensorDescription(
369+
key=AlphaESSNames.carbonReduction,
370+
name="Co2 Reduction",
371+
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
372+
device_class=SensorDeviceClass.WEIGHT,
373+
state_class=SensorStateClass.MEASUREMENT,
374+
icon="mdi:molecule-co2",
375+
),
376+
AlphaESSSensorDescription(
377+
key=AlphaESSNames.treePlanted,
378+
name="Trees Planted",
379+
native_unit_of_measurement=None,
380+
state_class=SensorStateClass.MEASUREMENT,
381+
icon="mdi:tree",
367382
)
368-
369383
]
370384

371385
LIMITED_SENSOR_DESCRIPTIONS: List[AlphaESSSensorDescription] = [
@@ -646,6 +660,21 @@
646660
device_class=SensorDeviceClass.POWER,
647661
state_class=SensorStateClass.MEASUREMENT,
648662
icon="mdi:flash",
663+
),
664+
AlphaESSSensorDescription(
665+
key=AlphaESSNames.carbonReduction,
666+
name="Carbon Reduction",
667+
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
668+
device_class=SensorDeviceClass.WEIGHT,
669+
state_class=SensorStateClass.MEASUREMENT,
670+
icon="mdi:molecule-co2",
671+
),
672+
AlphaESSSensorDescription(
673+
key=AlphaESSNames.treePlanted,
674+
name="Trees Planted",
675+
native_unit_of_measurement=None,
676+
state_class=SensorStateClass.MEASUREMENT,
677+
icon="mdi:tree",
649678
)
650679
]
651680

0 commit comments

Comments
 (0)