-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delta3 #375
Open
nalditopr
wants to merge
3
commits into
tolwi:main
Choose a base branch
from
nalditopr:delta3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Delta3 #375
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
custom_components/ecoflow_cloud/devices/internal/delta3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
from custom_components.ecoflow_cloud.api import EcoflowApiClient | ||
from custom_components.ecoflow_cloud.devices import const, BaseDevice | ||
from custom_components.ecoflow_cloud.entities import BaseSensorEntity | ||
from custom_components.ecoflow_cloud.number import ChargingPowerEntity, MaxBatteryLevelEntity, MinBatteryLevelEntity, \ | ||
MinGenStartLevelEntity, \ | ||
MaxGenStopLevelEntity | ||
from custom_components.ecoflow_cloud.select import DictSelectEntity, TimeoutDictSelectEntity | ||
from custom_components.ecoflow_cloud.sensor import LevelSensorEntity, WattsSensorEntity, RemainSensorEntity, \ | ||
TempSensorEntity, \ | ||
CyclesSensorEntity, InWattsSensorEntity, OutWattsSensorEntity, OutWattsDcSensorEntity, InWattsSolarSensorEntity, \ | ||
InVoltSolarSensorEntity, InAmpSolarSensorEntity, OutVoltDcSensorEntity, \ | ||
InEnergySensorEntity, OutEnergySensorEntity, MilliVoltSensorEntity, InMilliVoltSensorEntity, \ | ||
OutMilliVoltSensorEntity, AmpSensorEntity, CapacitySensorEntity, QuotaStatusSensorEntity | ||
from custom_components.ecoflow_cloud.switch import BeeperEntity, EnabledEntity | ||
|
||
|
||
class Delta3(BaseDevice): | ||
def sensors(self, client: EcoflowApiClient) -> list[BaseSensorEntity]: | ||
return [ | ||
LevelSensorEntity(client, self, "cmsBattSoc", const.MAIN_BATTERY_LEVEL) | ||
.attr("bmsDesignCap", const.ATTR_DESIGN_CAPACITY, 0) | ||
.attr("bmsMaster.fullCap", const.ATTR_FULL_CAPACITY, 0) | ||
.attr("bmsMaster.remainCap", const.ATTR_REMAIN_CAPACITY, 0), | ||
LevelSensorEntity(client, self, "bmsMaster.f32ShowSoc", const.MAIN_BATTERY_LEVEL_F32, False) | ||
.attr("bmsMaster.designCap", const.ATTR_DESIGN_CAPACITY, 0) | ||
.attr("bmsMaster.fullCap", const.ATTR_FULL_CAPACITY, 0) | ||
.attr("bmsMaster.remainCap", const.ATTR_REMAIN_CAPACITY, 0), | ||
CapacitySensorEntity(client, self, "bmsMaster.designCap", const.MAIN_DESIGN_CAPACITY, False), | ||
CapacitySensorEntity(client, self, "bmsMaster.fullCap", const.MAIN_FULL_CAPACITY, False), | ||
CapacitySensorEntity(client, self, "bmsMaster.remainCap", const.MAIN_REMAIN_CAPACITY, False), | ||
LevelSensorEntity(client, self, "bmsMaster.soh", const.SOH), | ||
|
||
LevelSensorEntity(client, self, "ems.lcdShowSoc", const.COMBINED_BATTERY_LEVEL), | ||
LevelSensorEntity(client, self, "ems.f32LcdShowSoc", const.COMBINED_BATTERY_LEVEL_F32, False), | ||
WattsSensorEntity(client, self, "pd.wattsInSum", const.TOTAL_IN_POWER), | ||
WattsSensorEntity(client, self, "pd.wattsOutSum", const.TOTAL_OUT_POWER), | ||
AmpSensorEntity(client, self, "bmsMaster.amp", const.MAIN_BATTERY_CURRENT), | ||
|
||
InWattsSensorEntity(client, self, "powGetAcIn", const.AC_IN_POWER), | ||
OutWattsSensorEntity(client, self, "powOutSumW", const.AC_OUT_POWER), | ||
|
||
InMilliVoltSensorEntity(client, self, "inv.acInVol", const.AC_IN_VOLT), | ||
OutMilliVoltSensorEntity(client, self, "inv.invOutVol", const.AC_OUT_VOLT), | ||
|
||
InWattsSolarSensorEntity(client, self, "mppt.inWatts", const.SOLAR_IN_POWER), | ||
InVoltSolarSensorEntity(client, self, "mppt.inVol", const.SOLAR_IN_VOLTAGE), | ||
InAmpSolarSensorEntity(client, self, "mppt.inAmp", const.SOLAR_IN_CURRENT), | ||
|
||
OutWattsDcSensorEntity(client, self, "mppt.outWatts", const.DC_OUT_POWER), | ||
OutVoltDcSensorEntity(client, self, "mppt.outVol", const.DC_OUT_VOLTAGE), | ||
|
||
OutWattsSensorEntity(client, self, "mppt.carOutWatts", const.DC_CAR_OUT_POWER), | ||
OutWattsSensorEntity(client, self, "mppt.dcdc12vWatts", const.DC_ANDERSON_OUT_POWER), | ||
|
||
OutWattsSensorEntity(client, self, "pd.typec1Watts", const.TYPEC_1_OUT_POWER), | ||
OutWattsSensorEntity(client, self, "pd.typec2Watts", const.TYPEC_2_OUT_POWER), | ||
|
||
OutWattsSensorEntity(client, self, "pd.usb1Watts", const.USB_1_OUT_POWER), | ||
OutWattsSensorEntity(client, self, "pd.usb2Watts", const.USB_2_OUT_POWER), | ||
|
||
OutWattsSensorEntity(client, self, "pd.qcUsb1Watts", const.USB_QC_1_OUT_POWER), | ||
OutWattsSensorEntity(client, self, "pd.qcUsb2Watts", const.USB_QC_2_OUT_POWER), | ||
|
||
RemainSensorEntity(client, self, "ems.chgRemainTime", const.CHARGE_REMAINING_TIME), | ||
RemainSensorEntity(client, self, "ems.dsgRemainTime", const.DISCHARGE_REMAINING_TIME), | ||
CyclesSensorEntity(client, self, "bmsMaster.cycles", const.CYCLES), | ||
|
||
TempSensorEntity(client, self, "bmsMaxCellTemp", const.BATTERY_TEMP) | ||
.attr("bmsMaster.minCellTemp", const.ATTR_MIN_CELL_TEMP, 0) | ||
.attr("bmsMaster.maxCellTemp", const.ATTR_MAX_CELL_TEMP, 0), | ||
TempSensorEntity(client, self, "bmsMaster.minCellTemp", const.MIN_CELL_TEMP, False), | ||
TempSensorEntity(client, self, "bmsMaster.maxCellTemp", const.MAX_CELL_TEMP, False), | ||
|
||
MilliVoltSensorEntity(client, self, "bmsMaster.vol", const.BATTERY_VOLT, False) | ||
.attr("bmsMaster.minCellVol", const.ATTR_MIN_CELL_VOLT, 0) | ||
.attr("bmsMaster.maxCellVol", const.ATTR_MAX_CELL_VOLT, 0), | ||
MilliVoltSensorEntity(client, self, "bmsMaster.minCellVol", const.MIN_CELL_VOLT, False), | ||
MilliVoltSensorEntity(client, self, "bmsMaster.maxCellVol", const.MAX_CELL_VOLT, False), | ||
|
||
# https://github.com/tolwi/hassio-ecoflow-cloud/discussions/87 | ||
InEnergySensorEntity(client, self, "pd.chgSunPower", const.SOLAR_IN_ENERGY), | ||
InEnergySensorEntity(client, self, "pd.chgPowerAc", const.CHARGE_AC_ENERGY), | ||
InEnergySensorEntity(client, self, "pd.chgPowerDc", const.CHARGE_DC_ENERGY), | ||
OutEnergySensorEntity(client, self, "pd.dsgPowerAc", const.DISCHARGE_AC_ENERGY), | ||
OutEnergySensorEntity(client, self, "pd.dsgPowerDc", const.DISCHARGE_DC_ENERGY), | ||
|
||
# Optional Slave Batteries | ||
LevelSensorEntity(client, self, "bmsSlave1.soc", const.SLAVE_N_BATTERY_LEVEL % 1, False, True) | ||
.attr("bmsSlave1.designCap", const.ATTR_DESIGN_CAPACITY, 0) | ||
.attr("bmsSlave1.fullCap", const.ATTR_FULL_CAPACITY, 0) | ||
.attr("bmsSlave1.remainCap", const.ATTR_REMAIN_CAPACITY, 0), | ||
LevelSensorEntity(client, self, "bmsSlave1.f32ShowSoc", const.SLAVE_N_BATTERY_LEVEL_F32 % 1, False, False) | ||
.attr("bmsSlave1.designCap", const.ATTR_DESIGN_CAPACITY, 0) | ||
.attr("bmsSlave1.fullCap", const.ATTR_FULL_CAPACITY, 0) | ||
.attr("bmsSlave1.remainCap", const.ATTR_REMAIN_CAPACITY, 0), | ||
CapacitySensorEntity(client, self, "bmsSlave1.designCap", const.SLAVE_N_DESIGN_CAPACITY % 1, False), | ||
CapacitySensorEntity(client, self, "bmsSlave1.fullCap", const.SLAVE_N_FULL_CAPACITY % 1, False), | ||
CapacitySensorEntity(client, self, "bmsSlave1.remainCap", const.SLAVE_N_REMAIN_CAPACITY % 1, False), | ||
LevelSensorEntity(client, self, "bmsSlave1.soh", const.SLAVE_N_SOH % 1), | ||
|
||
TempSensorEntity(client, self, "bmsSlave1.temp", const.SLAVE_N_BATTERY_TEMP % 1, False, True) | ||
.attr("bmsSlave1.minCellTemp", const.ATTR_MIN_CELL_TEMP, 0) | ||
.attr("bmsSlave1.maxCellTemp", const.ATTR_MAX_CELL_TEMP, 0), | ||
WattsSensorEntity(client, self, "bmsSlave1.inputWatts", const.SLAVE_N_IN_POWER % 1, False, True), | ||
WattsSensorEntity(client, self, "bmsSlave1.outputWatts", const.SLAVE_N_OUT_POWER % 1, False, True), | ||
|
||
LevelSensorEntity(client, self, "bmsSlave2.soc", const.SLAVE_N_BATTERY_LEVEL % 2, False, True) | ||
.attr("bmsSlave2.designCap", const.ATTR_DESIGN_CAPACITY, 0) | ||
.attr("bmsSlave2.fullCap", const.ATTR_FULL_CAPACITY, 0) | ||
.attr("bmsSlave2.remainCap", const.ATTR_REMAIN_CAPACITY, 0), | ||
LevelSensorEntity(client, self, "bmsSlave2.f32ShowSoc", const.SLAVE_N_BATTERY_LEVEL_F32 % 2, False, False) | ||
.attr("bmsSlave2.designCap", const.ATTR_DESIGN_CAPACITY, 0) | ||
.attr("bmsSlave2.fullCap", const.ATTR_FULL_CAPACITY, 0) | ||
.attr("bmsSlave2.remainCap", const.ATTR_REMAIN_CAPACITY, 0), | ||
CapacitySensorEntity(client, self, "bmsSlave2.designCap", const.SLAVE_N_DESIGN_CAPACITY % 2, False), | ||
CapacitySensorEntity(client, self, "bmsSlave2.fullCap", const.SLAVE_N_FULL_CAPACITY % 2, False), | ||
CapacitySensorEntity(client, self, "bmsSlave2.remainCap", const.SLAVE_N_REMAIN_CAPACITY % 2, False), | ||
LevelSensorEntity(client, self, "bmsSlave2.soh", const.SLAVE_N_SOH % 2), | ||
MilliVoltSensorEntity(client, self, "bmsSlave1.vol", const.SLAVE_N_BATTERY_VOLT % 1, False), | ||
MilliVoltSensorEntity(client, self, "bmsSlave1.minCellVol", const.SLAVE_N_MIN_CELL_VOLT % 1, False), | ||
MilliVoltSensorEntity(client, self, "bmsSlave1.maxCellVol", const.SLAVE_N_MAX_CELL_VOLT % 1, False), | ||
AmpSensorEntity(client, self, "bmsSlave1.amp", const.SLAVE_N_BATTERY_CURRENT % 1, False), | ||
MilliVoltSensorEntity(client, self, "bmsSlave2.vol", const.SLAVE_N_BATTERY_VOLT % 2, False), | ||
MilliVoltSensorEntity(client, self, "bmsSlave2.minCellVol", const.SLAVE_N_MIN_CELL_VOLT % 2, False), | ||
MilliVoltSensorEntity(client, self, "bmsSlave2.maxCellVol", const.SLAVE_N_MAX_CELL_VOLT % 2, False), | ||
AmpSensorEntity(client, self, "bmsSlave2.amp", const.SLAVE_N_BATTERY_CURRENT % 2, False), | ||
TempSensorEntity(client, self, "bmsSlave2.temp", const.SLAVE_N_BATTERY_TEMP % 2, False, True) | ||
.attr("bmsSlave2.minCellTemp", const.ATTR_MIN_CELL_TEMP, 0) | ||
.attr("bmsSlave2.maxCellTemp", const.ATTR_MAX_CELL_TEMP, 0), | ||
WattsSensorEntity(client, self, "bmsSlave2.inputWatts", const.SLAVE_N_IN_POWER % 2, False, True), | ||
WattsSensorEntity(client, self, "bmsSlave2.outputWatts", const.SLAVE_N_OUT_POWER % 2, False, True), | ||
CyclesSensorEntity(client, self, "bmsSlave1.cycles", const.SLAVE_N_CYCLES % 1, False), | ||
CyclesSensorEntity(client, self, "bmsSlave2.cycles", const.SLAVE_N_CYCLES % 2, False), | ||
QuotaStatusSensorEntity(client, self) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from .data_bridge import to_plain | ||
from ..internal.delta3 import Delta3 as InternalDelta3 | ||
from ...api import EcoflowApiClient | ||
from ...sensor import StatusSensorEntity | ||
|
||
|
||
class Delta3(InternalDelta3): | ||
|
||
def _prepare_data(self, raw_data) -> dict[str, any]: | ||
res = super()._prepare_data(raw_data) | ||
res = to_plain(res) | ||
return res | ||
|
||
def _status_sensor(self, client: EcoflowApiClient) -> StatusSensorEntity: | ||
return StatusSensorEntity(client, self) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove please this change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need to define an internal device - place all sensors in the public Delta3 profile