Skip to content

Commit 83346a1

Browse files
Remove rounding (#95)
1 parent 6bc66a1 commit 83346a1

1 file changed

Lines changed: 58 additions & 115 deletions

File tree

e3dc/_e3dc.py

Lines changed: 58 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -391,17 +391,9 @@ def poll_rscp(self, keepAlive=False):
391391
home = self.sendRequestTag(RscpTag.EMS_REQ_POWER_HOME, keepAlive=True)
392392
grid = self.sendRequestTag(RscpTag.EMS_REQ_POWER_GRID, keepAlive=True)
393393
wb = self.sendRequestTag(RscpTag.EMS_REQ_POWER_WB_ALL, keepAlive=True)
394-
395-
sc = round(
396-
self.sendRequestTag(RscpTag.EMS_REQ_SELF_CONSUMPTION, keepAlive=True),
397-
2,
398-
)
399-
394+
sc = self.sendRequestTag(RscpTag.EMS_REQ_SELF_CONSUMPTION, keepAlive=True)
400395
# last call, use keepAlive value
401-
autarky = round(
402-
self.sendRequestTag(RscpTag.EMS_REQ_AUTARKY, keepAlive=keepAlive),
403-
2,
404-
)
396+
autarky = self.sendRequestTag(RscpTag.EMS_REQ_AUTARKY, keepAlive=keepAlive)
405397

406398
outObj = {
407399
"autarky": autarky,
@@ -975,10 +967,11 @@ def get_system_info_static(self, keepAlive=False):
975967
Args:
976968
keepAlive (Optional[bool]): True to keep connection alive
977969
"""
978-
self.deratePercent = round(
970+
self.deratePercent = (
979971
self.sendRequestTag(RscpTag.EMS_REQ_DERATE_AT_PERCENT_VALUE, keepAlive=True)
980972
* 100
981973
)
974+
982975
self.deratePower = self.sendRequestTag(
983976
RscpTag.EMS_REQ_DERATE_AT_POWER_VALUE, keepAlive=True
984977
)
@@ -1288,12 +1281,10 @@ def get_battery_data(self, batIndex=None, dcbs=None, keepAlive=False):
12881281
outObj = {
12891282
"asoc": rscpFindTagIndex(req, RscpTag.BAT_ASOC),
12901283
"chargeCycles": rscpFindTagIndex(req, RscpTag.BAT_CHARGE_CYCLES),
1291-
"current": round(rscpFindTagIndex(req, RscpTag.BAT_CURRENT), 2),
1284+
"current": rscpFindTagIndex(req, RscpTag.BAT_CURRENT),
12921285
"dcbCount": dcbCount,
12931286
"dcbs": {},
1294-
"designCapacity": round(
1295-
rscpFindTagIndex(req, RscpTag.BAT_DESIGN_CAPACITY), 2
1296-
),
1287+
"designCapacity": rscpFindTagIndex(req, RscpTag.BAT_DESIGN_CAPACITY),
12971288
"deviceConnected": rscpFindTagIndex(
12981289
deviceStateContainer, RscpTag.BAT_DEVICE_CONNECTED
12991290
),
@@ -1304,48 +1295,36 @@ def get_battery_data(self, batIndex=None, dcbs=None, keepAlive=False):
13041295
"deviceWorking": rscpFindTagIndex(
13051296
deviceStateContainer, RscpTag.BAT_DEVICE_WORKING
13061297
),
1307-
"eodVoltage": round(rscpFindTagIndex(req, RscpTag.BAT_EOD_VOLTAGE), 2),
1298+
"eodVoltage": rscpFindTagIndex(req, RscpTag.BAT_EOD_VOLTAGE),
13081299
"errorCode": rscpFindTagIndex(req, RscpTag.BAT_ERROR_CODE),
13091300
"fcc": rscpFindTagIndex(req, RscpTag.BAT_FCC),
13101301
"index": batIndex,
1311-
"maxBatVoltage": round(
1312-
rscpFindTagIndex(req, RscpTag.BAT_MAX_BAT_VOLTAGE), 2
1302+
"maxBatVoltage": rscpFindTagIndex(req, RscpTag.BAT_MAX_BAT_VOLTAGE),
1303+
"maxChargeCurrent": rscpFindTagIndex(req, RscpTag.BAT_MAX_CHARGE_CURRENT),
1304+
"maxDischargeCurrent": rscpFindTagIndex(
1305+
req, RscpTag.BAT_MAX_DISCHARGE_CURRENT
13131306
),
1314-
"maxChargeCurrent": round(
1315-
rscpFindTagIndex(req, RscpTag.BAT_MAX_CHARGE_CURRENT), 2
1307+
"maxDcbCellTemp": rscpFindTagIndex(
1308+
req, RscpTag.BAT_MAX_DCB_CELL_TEMPERATURE
13161309
),
1317-
"maxDischargeCurrent": round(
1318-
rscpFindTagIndex(req, RscpTag.BAT_MAX_DISCHARGE_CURRENT), 2
1310+
"minDcbCellTemp": rscpFindTagIndex(
1311+
req, RscpTag.BAT_MIN_DCB_CELL_TEMPERATURE
13191312
),
1320-
"maxDcbCellTemp": round(
1321-
rscpFindTagIndex(req, RscpTag.BAT_MAX_DCB_CELL_TEMPERATURE), 2
1322-
),
1323-
"minDcbCellTemp": round(
1324-
rscpFindTagIndex(req, RscpTag.BAT_MIN_DCB_CELL_TEMPERATURE), 2
1325-
),
1326-
"moduleVoltage": round(
1327-
rscpFindTagIndex(req, RscpTag.BAT_MODULE_VOLTAGE), 2
1328-
),
1329-
"rc": round(rscpFindTagIndex(req, RscpTag.BAT_RC), 2),
1330-
"readyForShutdown": round(
1331-
rscpFindTagIndex(req, RscpTag.BAT_READY_FOR_SHUTDOWN), 2
1332-
),
1333-
"rsoc": round(rscpFindTagIndex(req, RscpTag.BAT_RSOC), 2),
1334-
"rsocReal": round(rscpFindTagIndex(req, RscpTag.BAT_RSOC_REAL), 2),
1313+
"moduleVoltage": rscpFindTagIndex(req, RscpTag.BAT_MODULE_VOLTAGE),
1314+
"rc": rscpFindTagIndex(req, RscpTag.BAT_RC),
1315+
"readyForShutdown": rscpFindTagIndex(req, RscpTag.BAT_READY_FOR_SHUTDOWN),
1316+
"rsoc": rscpFindTagIndex(req, RscpTag.BAT_RSOC),
1317+
"rsocReal": rscpFindTagIndex(req, RscpTag.BAT_RSOC_REAL),
13351318
"statusCode": rscpFindTagIndex(req, RscpTag.BAT_STATUS_CODE),
1336-
"terminalVoltage": round(
1337-
rscpFindTagIndex(req, RscpTag.BAT_TERMINAL_VOLTAGE), 2
1338-
),
1319+
"terminalVoltage": rscpFindTagIndex(req, RscpTag.BAT_TERMINAL_VOLTAGE),
13391320
"totalUseTime": rscpFindTagIndex(req, RscpTag.BAT_TOTAL_USE_TIME),
13401321
"totalDischargeTime": rscpFindTagIndex(
13411322
req, RscpTag.BAT_TOTAL_DISCHARGE_TIME
13421323
),
13431324
"trainingMode": rscpFindTagIndex(req, RscpTag.BAT_TRAINING_MODE),
1344-
"usuableCapacity": round(
1345-
rscpFindTagIndex(req, RscpTag.BAT_USABLE_CAPACITY), 2
1346-
),
1347-
"usuableRemainingCapacity": round(
1348-
rscpFindTagIndex(req, RscpTag.BAT_USABLE_REMAINING_CAPACITY), 2
1325+
"usuableCapacity": rscpFindTagIndex(req, RscpTag.BAT_USABLE_CAPACITY),
1326+
"usuableRemainingCapacity": rscpFindTagIndex(
1327+
req, RscpTag.BAT_USABLE_REMAINING_CAPACITY
13491328
),
13501329
}
13511330

@@ -1398,7 +1377,7 @@ def get_battery_data(self, batIndex=None, dcbs=None, keepAlive=False):
13981377
temperatures = []
13991378
sensorCount = rscpFindTagIndex(info, RscpTag.BAT_DCB_NR_SENSOR)
14001379
for sensor in range(0, sensorCount):
1401-
temperatures.append(round(temperatures_raw[sensor][2], 2))
1380+
temperatures.append(temperatures_raw[sensor][2])
14021381

14031382
# Set voltages, if available for the device
14041383
voltages = rscpFindTag(req, RscpTag.BAT_DCB_ALL_CELL_VOLTAGES)
@@ -1410,7 +1389,7 @@ def get_battery_data(self, batIndex=None, dcbs=None, keepAlive=False):
14101389
voltages = []
14111390
seriesCellCount = rscpFindTagIndex(info, RscpTag.BAT_DCB_NR_SERIES_CELL)
14121391
for cell in range(0, seriesCellCount):
1413-
voltages.append(round(voltages_raw[cell][2], 2))
1392+
voltages.append(voltages_raw[cell][2])
14141393

14151394
dcbobj = {
14161395
"current": rscpFindTagIndex(info, RscpTag.BAT_DCB_CURRENT),
@@ -1705,11 +1684,8 @@ def get_pvi_data(self, pviIndex=None, strings=None, phases=None, keepAlive=False
17051684
keepAlive=True,
17061685
)
17071686
outObj["temperature"]["values"].append(
1708-
round(
1709-
rscpFindTagIndex(
1710-
rscpFindTag(req, RscpTag.PVI_TEMPERATURE), RscpTag.PVI_VALUE
1711-
),
1712-
2,
1687+
rscpFindTagIndex(
1688+
rscpFindTag(req, RscpTag.PVI_TEMPERATURE), RscpTag.PVI_VALUE
17131689
)
17141690
)
17151691

@@ -1739,50 +1715,29 @@ def get_pvi_data(self, pviIndex=None, strings=None, phases=None, keepAlive=False
17391715
keepAlive=True,
17401716
)
17411717
phaseobj = {
1742-
"power": round(
1743-
rscpFindTagIndex(
1744-
rscpFindTag(req, RscpTag.PVI_AC_POWER), RscpTag.PVI_VALUE
1745-
),
1746-
2,
1747-
),
1748-
"voltage": round(
1749-
rscpFindTagIndex(
1750-
rscpFindTag(req, RscpTag.PVI_AC_VOLTAGE), RscpTag.PVI_VALUE
1751-
),
1752-
2,
1718+
"power": rscpFindTagIndex(
1719+
rscpFindTag(req, RscpTag.PVI_AC_POWER), RscpTag.PVI_VALUE
17531720
),
1754-
"current": round(
1755-
rscpFindTagIndex(
1756-
rscpFindTag(req, RscpTag.PVI_AC_CURRENT), RscpTag.PVI_VALUE
1757-
),
1758-
2,
1721+
"voltage": rscpFindTagIndex(
1722+
rscpFindTag(req, RscpTag.PVI_AC_VOLTAGE), RscpTag.PVI_VALUE
17591723
),
1760-
"apparentPower": round(
1761-
rscpFindTag(
1762-
rscpFindTag(req, RscpTag.PVI_AC_APPARENTPOWER),
1763-
RscpTag.PVI_VALUE,
1764-
)[2],
1765-
2,
1724+
"current": rscpFindTagIndex(
1725+
rscpFindTag(req, RscpTag.PVI_AC_CURRENT), RscpTag.PVI_VALUE
17661726
),
1767-
"reactivePower": round(
1768-
rscpFindTagIndex(
1769-
rscpFindTag(req, RscpTag.PVI_AC_REACTIVEPOWER),
1770-
RscpTag.PVI_VALUE,
1771-
),
1772-
2,
1727+
"apparentPower": rscpFindTag(
1728+
rscpFindTag(req, RscpTag.PVI_AC_APPARENTPOWER),
1729+
RscpTag.PVI_VALUE,
1730+
)[2],
1731+
"reactivePower": rscpFindTagIndex(
1732+
rscpFindTag(req, RscpTag.PVI_AC_REACTIVEPOWER),
1733+
RscpTag.PVI_VALUE,
17731734
),
1774-
"energyAll": round(
1775-
rscpFindTagIndex(
1776-
rscpFindTag(req, RscpTag.PVI_AC_ENERGY_ALL), RscpTag.PVI_VALUE
1777-
),
1778-
2,
1735+
"energyAll": rscpFindTagIndex(
1736+
rscpFindTag(req, RscpTag.PVI_AC_ENERGY_ALL), RscpTag.PVI_VALUE
17791737
),
1780-
"energyGridConsumption": round(
1781-
rscpFindTagIndex(
1782-
rscpFindTag(req, RscpTag.PVI_AC_ENERGY_GRID_CONSUMPTION),
1783-
RscpTag.PVI_VALUE,
1784-
),
1785-
2,
1738+
"energyGridConsumption": rscpFindTagIndex(
1739+
rscpFindTag(req, RscpTag.PVI_AC_ENERGY_GRID_CONSUMPTION),
1740+
RscpTag.PVI_VALUE,
17861741
),
17871742
}
17881743
outObj["phases"][phase] = phaseobj
@@ -1812,30 +1767,18 @@ def get_pvi_data(self, pviIndex=None, strings=None, phases=None, keepAlive=False
18121767
else keepAlive, # last request should honor keepAlive
18131768
)
18141769
stringobj = {
1815-
"power": round(
1816-
rscpFindTagIndex(
1817-
rscpFindTag(req, RscpTag.PVI_DC_POWER), RscpTag.PVI_VALUE
1818-
),
1819-
2,
1770+
"power": rscpFindTagIndex(
1771+
rscpFindTag(req, RscpTag.PVI_DC_POWER), RscpTag.PVI_VALUE
18201772
),
1821-
"voltage": round(
1822-
rscpFindTagIndex(
1823-
rscpFindTag(req, RscpTag.PVI_DC_VOLTAGE), RscpTag.PVI_VALUE
1824-
),
1825-
2,
1773+
"voltage": rscpFindTagIndex(
1774+
rscpFindTag(req, RscpTag.PVI_DC_VOLTAGE), RscpTag.PVI_VALUE
18261775
),
1827-
"current": round(
1828-
rscpFindTagIndex(
1829-
rscpFindTag(req, RscpTag.PVI_DC_CURRENT), RscpTag.PVI_VALUE
1830-
),
1831-
2,
1776+
"current": rscpFindTagIndex(
1777+
rscpFindTag(req, RscpTag.PVI_DC_CURRENT), RscpTag.PVI_VALUE
18321778
),
1833-
"energyAll": round(
1834-
rscpFindTagIndex(
1835-
rscpFindTag(req, RscpTag.PVI_DC_STRING_ENERGY_ALL),
1836-
RscpTag.PVI_VALUE,
1837-
),
1838-
2,
1779+
"energyAll": rscpFindTagIndex(
1780+
rscpFindTag(req, RscpTag.PVI_DC_STRING_ENERGY_ALL),
1781+
RscpTag.PVI_VALUE,
18391782
),
18401783
}
18411784
outObj["strings"][string] = stringobj
@@ -2004,9 +1947,9 @@ def get_powermeter_data(self, pmIndex=None, keepAlive=False):
20041947
},
20051948
"type": rscpFindTagIndex(res, RscpTag.PM_TYPE),
20061949
"voltage": {
2007-
"L1": round(rscpFindTagIndex(res, RscpTag.PM_VOLTAGE_L1), 4),
2008-
"L2": round(rscpFindTagIndex(res, RscpTag.PM_VOLTAGE_L2), 4),
2009-
"L3": round(rscpFindTagIndex(res, RscpTag.PM_VOLTAGE_L3), 4),
1950+
"L1": rscpFindTagIndex(res, RscpTag.PM_VOLTAGE_L1),
1951+
"L2": rscpFindTagIndex(res, RscpTag.PM_VOLTAGE_L2),
1952+
"L3": rscpFindTagIndex(res, RscpTag.PM_VOLTAGE_L3),
20101953
},
20111954
}
20121955
return outObj

0 commit comments

Comments
 (0)