Skip to content

Commit

Permalink
Solve legacy unit-issues (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
LAdegeest authored Jun 24, 2024
1 parent 3678dc4 commit 2cca9a3
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions custom_components/saj_esolar/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
CONF_USERNAME,
CONF_PASSWORD,
CONF_SENSORS,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
PERCENTAGE,
UnitOfEnergy,
UnitOfPower,
)

CONF_PLANT_ID: Final = "plant_id"
Expand Down Expand Up @@ -131,7 +131,7 @@ def add_years(d, years):
key="nowPower",
name="nowPower",
icon="mdi:solar-power",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
),
SensorEntityDescription(
Expand All @@ -148,28 +148,28 @@ def add_years(d, years):
key="todayElectricity",
name="todayElectricity",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
),
SensorEntityDescription(
key="monthElectricity",
name="monthElectricity",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
),
SensorEntityDescription(
key="yearElectricity",
name="yearElectricity",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
),
SensorEntityDescription(
key="totalElectricity",
name="totalElectricity",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
Expand All @@ -182,22 +182,22 @@ def add_years(d, years):
key="totalBuyElec",
name="totalBuyElec",
icon="mdi:solar-panel",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="totalConsumpElec",
name="totalConsumpElec",
icon="mdi:solar-panel",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
),
SensorEntityDescription(
key="totalSellElec",
name="totalSellElec",
icon="mdi:solar-panel",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
Expand Down Expand Up @@ -265,44 +265,44 @@ def add_years(d, years):
key="peakPower",
name="peakPower",
icon="mdi:solar-panel",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
),
SensorEntityDescription(
key="systemPower",
name="systemPower",
icon="mdi:solar-panel",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
),
SensorEntityDescription(
key="pvElec",
name="pvElec",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
),
SensorEntityDescription(
key="useElec",
name="useElec",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="buyElec",
name="buyElec",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="sellElec",
name="sellElec",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
Expand Down Expand Up @@ -330,14 +330,14 @@ def add_years(d, years):
key="selfConsumedEnergy1",
name="selfConsumedEnergy1",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
),
SensorEntityDescription(
key="selfConsumedEnergy2",
name="selfConsumedEnergy2",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
),
SensorEntityDescription(
Expand All @@ -354,50 +354,50 @@ def add_years(d, years):
key="totalGridPower",
name="totalGridPower",
icon="mdi:solar-panel",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
),
SensorEntityDescription(
key="totalLoadPower",
name="totalLoadPower",
icon="mdi:solar-panel",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
),
SensorEntityDescription(
key="totalPvgenPower",
name="totalPvgenPower",
icon="mdi:solar-panel",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
),
SensorEntityDescription(
key="totalPvEnergy",
name="totalPvEnergy",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="totalLoadEnergy",
name="totalLoadEnergy",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="totalBuyEnergy",
name="totalBuyEnergy",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="totalSellEnergy",
name="totalSellEnergy",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
Expand Down Expand Up @@ -434,13 +434,13 @@ def add_years(d, years):
key="batteryPower",
name="batteryPower",
icon="mdi:solar-panel-large",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
),
SensorEntityDescription(
key="gridPower",
name="gridPower",
icon="mdi:solar-panel-large",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
),
SensorEntityDescription(
key="gridDirection",
Expand All @@ -456,7 +456,7 @@ def add_years(d, years):
key="outPower",
name="outPower",
icon="mdi:solar-panel-large",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
),
SensorEntityDescription(
key="outPutDirection",
Expand All @@ -477,15 +477,15 @@ def add_years(d, years):
key="chargeElec",
name="chargeElec",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="dischargeElec",
name="dischargeElec",
icon="mdi:solar-panel-large",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
Expand Down

0 comments on commit 2cca9a3

Please sign in to comment.