Skip to content
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

Update models.py: Add reactive power readings #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/rctmon/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ class GridReadings(AbstractReadings):
power_l2: Optional[float] = None
#: g_sync.p_ac_sc[2]
power_l3: Optional[float] = None
#: g_sync.q_ac[0]
power_reactive_l1: Optional[float] = None
#: g_sync.q_ac[1]
power_reactive_l2: Optional[float] = None
#: g_sync.q_ac[2]
power_reactive_l3: Optional[float] = None
#: g_sync.u_l_rms[0]
voltage_l1: Optional[float] = None
#: g_sync.u_l_rms[1]
Expand Down Expand Up @@ -259,6 +265,16 @@ def collect(self, name: str) -> Generator:
power.add_metric([name, 'l3'], self.power_l3)
yield power

power_reactive = GaugeMetricFamily('rctmon_grid_power_reactive', 'Power reactive to or from the grid by phase',
labels=['inverter', 'phase'], unit='var')
if self.power_reactive_l1 is not None:
power_reactive.add_metric([name, 'l1'], self.power_reactive_l1)
if self.power_reactive_l2 is not None:
power_reactive.add_metric([name, 'l2'], self.power_reactive_l2)
if self.power_reactive_l3 is not None:
power_reactive.add_metric([name, 'l3'], self.power_reactive_l3)
yield power_reactive

voltage = GaugeMetricFamily('rctmon_grid_voltage', 'Grid voltage by phase', labels=['inverter', 'phase'],
unit='volt')
if self.voltage_l1 is not None:
Expand Down