uprava adutiu - nacitani dalsich registru, uprava ekonomiky
This commit is contained in:
@@ -22,6 +22,10 @@ DEYE_REG_BATTERY_POWER_FLOW = 590
|
||||
DEYE_REG_GRID_TOTAL_POWER = 625
|
||||
DEYE_REG_GEN_PORT_POWER = 667
|
||||
DEYE_REG_LOAD_TOTAL_POWER = 653
|
||||
DEYE_REG_GRID_IMPORT_TOTAL_LO = 522
|
||||
DEYE_REG_GRID_IMPORT_TOTAL_HI = 523
|
||||
DEYE_REG_GRID_EXPORT_TOTAL_LO = 524
|
||||
DEYE_REG_GRID_EXPORT_TOTAL_HI = 525
|
||||
DEYE_REG_PV1_POWER = 672
|
||||
DEYE_REG_PV2_POWER = 673
|
||||
|
||||
@@ -67,7 +71,12 @@ async def poll_inverter(site_id: int, db: asyncpg.Connection) -> None:
|
||||
pv1_power = await mb.read_register_signed(DEYE_REG_PV1_POWER)
|
||||
pv2_power = await mb.read_register_signed(DEYE_REG_PV2_POWER)
|
||||
gen_port_power = await mb.read_register_signed(DEYE_REG_GEN_PORT_POWER)
|
||||
grid_energy_regs = await mb.read_holding_registers(
|
||||
DEYE_REG_GRID_IMPORT_TOTAL_LO, 4
|
||||
)
|
||||
pv_power_w = aggregate_pv_production_w(pv1_power, pv2_power, gen_port_power)
|
||||
grid_import_total_wh = (grid_energy_regs[1] << 16 | grid_energy_regs[0]) * 100
|
||||
grid_export_total_wh = (grid_energy_regs[3] << 16 | grid_energy_regs[2]) * 100
|
||||
|
||||
logger.debug("inverter:%s Deye run_state raw=%s", code, run_state)
|
||||
|
||||
@@ -79,6 +88,7 @@ async def poll_inverter(site_id: int, db: asyncpg.Connection) -> None:
|
||||
battery_soc_percent, battery_power_w,
|
||||
batt_charge_today_wh, batt_discharge_today_wh,
|
||||
grid_power_w, load_power_w,
|
||||
grid_import_total_wh, grid_export_total_wh,
|
||||
run_state
|
||||
)
|
||||
VALUES (
|
||||
@@ -87,7 +97,8 @@ async def poll_inverter(site_id: int, db: asyncpg.Connection) -> None:
|
||||
$8, $9,
|
||||
$10, $11,
|
||||
$12, $13,
|
||||
$14
|
||||
$14, $15,
|
||||
$16
|
||||
)
|
||||
ON CONFLICT (inverter_id, measured_at) DO NOTHING
|
||||
""",
|
||||
@@ -104,6 +115,8 @@ async def poll_inverter(site_id: int, db: asyncpg.Connection) -> None:
|
||||
batt_discharge_today,
|
||||
grid_power,
|
||||
load_power,
|
||||
grid_import_total_wh,
|
||||
grid_export_total_wh,
|
||||
run_state,
|
||||
)
|
||||
inv_temp: float | None = None
|
||||
|
||||
Reference in New Issue
Block a user