Skip to content

Commit

Permalink
Merge pull request #223 from kbialek/feature/new-string-metrics
Browse files Browse the repository at this point in the history
Add new string inverter metrics
  • Loading branch information
kbialek authored Feb 5, 2025
2 parents 083a7d8 + befb386 commit df875e9
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 21 deletions.
6 changes: 3 additions & 3 deletions docs/metric_group_micro.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
|---|---|:-:|:-:|:-:|:-:|:-:|
|Production today|`day_energy`|kWh|60|3c|U_WORD|0.1|
|Production Total|`total_energy`|kWh|63,64|3f,40|U_DWORD (LW,HW)|0.1|
|Phase1 Voltage|`ac/l1/voltage`|V|73|49|U_WORD|0.1|
|Phase1 Current|`ac/l1/current`|A|76|4c|U_WORD|0.1|
|Phase1 Power|`ac/l1/power`|W|computed|computed|n/a|1|
|Grid L1 Voltage|`ac/l1/voltage`|V|73|49|U_WORD|0.1|
|Grid L1 Current|`ac/l1/current`|A|76|4c|U_WORD|0.1|
|Grid L1 Power|`ac/l1/power`|W|computed|computed|n/a|1|
|AC Freq|`ac/freq`|Hz|79|4f|U_WORD|0.01|
|Uptime|`uptime`|minutes|62|3e|U_WORD|1|
|PV1 Voltage|`dc/pv1/voltage`|V|109|6d|U_WORD|0.1|
Expand Down
29 changes: 20 additions & 9 deletions docs/metric_group_string.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@
|---|---|:-:|:-:|:-:|:-:|:-:|
|Production today|`day_energy`|kWh|60|3c|U_WORD|0.1|
|Production Total|`total_energy`|kWh|63,64|3f,40|U_DWORD (LW,HW)|0.1|
|Phase1 Voltage|`ac/l1/voltage`|V|73|49|U_WORD|0.1|
|Phase1 Current|`ac/l1/current`|A|76|4c|U_WORD|0.1|
|Phase1 Power|`ac/l1/power`|W|computed|computed|n/a|1|
|Phase2 Voltage|`ac/l2/voltage`|V|74|4a|U_WORD|0.1|
|Phase2 Current|`ac/l2/current`|A|77|4d|U_WORD|0.1|
|Phase2 Power|`ac/l2/power`|W|computed|computed|n/a|1|
|Phase3 Voltage|`ac/l3/voltage`|V|75|4b|U_WORD|0.1|
|Phase3 Current|`ac/l3/current`|A|78|4e|U_WORD|0.1|
|Phase3 Power|`ac/l3/power`|W|computed|computed|n/a|1|
|Grid L1 Voltage|`ac/l1/voltage`|V|73|49|U_WORD|0.1|
|Grid L1 Current|`ac/l1/current`|A|76|4c|U_WORD|0.1|
|Grid L1 Power|`ac/l1/power`|W|computed|computed|n/a|1|
|Grid L2 Voltage|`ac/l2/voltage`|V|74|4a|U_WORD|0.1|
|Grid L2 Current|`ac/l2/current`|A|77|4d|U_WORD|0.1|
|Grid L2 Power|`ac/l2/power`|W|computed|computed|n/a|1|
|Grid L3 Voltage|`ac/l3/voltage`|V|75|4b|U_WORD|0.1|
|Grid L3 Current|`ac/l3/current`|A|78|4e|U_WORD|0.1|
|Grid L3 Power|`ac/l3/power`|W|computed|computed|n/a|1|
|Grid L12 Voltage|`ac/l12/voltage`|V|70|46|U_WORD|0.1|
|Grid L23 Voltage|`ac/l23/voltage`|V|71|47|U_WORD|0.1|
|Grid L31 Voltage|`ac/l31/voltage`|V|72|48|U_WORD|0.1|
|Grid Power|`ac/grid/power`|W|203,204|cb,cc|U_DWORD (LW,HW)|1.0|
|Load Power|`ac/ups/power`|W|198,199|c6,c7|U_DWORD (LW,HW)|1.0|
|AC Freq|`ac/freq`|Hz|79|4f|U_WORD|0.01|
|Uptime|`uptime`|minutes|62|3e|U_WORD|1|
|Daily Load Consumption|`ac/ups/daily_energy`|kWh|200|c8|U_WORD|0.01|
|Total Load Consumption|`ac/ups/total_energy`|kWh|201,202|c9,ca|U_DWORD (LW,HW)|0.1|
|Daily Energy Sold|`ac/daily_energy_sold`|kWh|205|cd|U_WORD|0.01|
|Total Energy Sold|`ac/total_energy_sold`|kWh|206,207|ce,cf|U_DWORD (LW,HW)|0.1|
|Daily Energy Bought|`ac/daily_energy_bought`|kWh|208|d0|U_WORD|0.01|
|Total Energy Bought|`ac/total_energy_bought`|kWh|209,210|d1,d2|U_DWORD (LW,HW)|0.1|
|PV1 Voltage|`dc/pv1/voltage`|V|109|6d|U_WORD|0.1|
|PV1 Current|`dc/pv1/current`|A|110|6e|U_WORD|0.1|
|PV1 Power|`dc/pv1/power`|W|computed|computed|n/a|1|
Expand Down
71 changes: 62 additions & 9 deletions src/deye_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

# AC Phase 1
phase1_voltage_sensor = SingleRegisterSensor(
"Phase1 Voltage", 0x49, 0.1, mqtt_topic_suffix="ac/l1/voltage", unit="V", groups=["string", "micro"]
"Grid L1 Voltage", 0x49, 0.1, mqtt_topic_suffix="ac/l1/voltage", unit="V", groups=["string", "micro"]
)
phase1_current_sensor = SingleRegisterSensor(
"Phase1 Current", 0x4C, 0.1, mqtt_topic_suffix="ac/l1/current", unit="A", groups=["string", "micro"]
"Grid L1 Current", 0x4C, 0.1, mqtt_topic_suffix="ac/l1/current", unit="A", groups=["string", "micro"]
)
phase1_power_sensor = ComputedPowerSensor(
"Phase1 Power",
"Grid L1 Power",
phase1_voltage_sensor,
phase1_current_sensor,
mqtt_topic_suffix="ac/l1/power",
Expand All @@ -49,13 +49,13 @@

# AC Phase 2
phase2_voltage_sensor = SingleRegisterSensor(
"Phase2 Voltage", 0x4A, 0.1, mqtt_topic_suffix="ac/l2/voltage", unit="V", groups=["string"]
"Grid L2 Voltage", 0x4A, 0.1, mqtt_topic_suffix="ac/l2/voltage", unit="V", groups=["string"]
)
phase2_current_sensor = SingleRegisterSensor(
"Phase2 Current", 0x4D, 0.1, mqtt_topic_suffix="ac/l2/current", unit="A", groups=["string"]
"Grid L2 Current", 0x4D, 0.1, mqtt_topic_suffix="ac/l2/current", unit="A", groups=["string"]
)
phase2_power_sensor = ComputedPowerSensor(
"Phase2 Power",
"Grid L2 Power",
phase2_voltage_sensor,
phase2_current_sensor,
mqtt_topic_suffix="ac/l2/power",
Expand All @@ -65,20 +65,41 @@

# AC Phase 3
phase3_voltage_sensor = SingleRegisterSensor(
"Phase3 Voltage", 0x4B, 0.1, mqtt_topic_suffix="ac/l3/voltage", unit="V", groups=["string"]
"Grid L3 Voltage", 0x4B, 0.1, mqtt_topic_suffix="ac/l3/voltage", unit="V", groups=["string"]
)
phase3_current_sensor = SingleRegisterSensor(
"Phase3 Current", 0x4E, 0.1, mqtt_topic_suffix="ac/l3/current", unit="A", groups=["string"]
"Grid L3 Current", 0x4E, 0.1, mqtt_topic_suffix="ac/l3/current", unit="A", groups=["string"]
)
phase3_power_sensor = ComputedPowerSensor(
"Phase3 Power",
"Grid L3 Power",
phase3_voltage_sensor,
phase3_current_sensor,
mqtt_topic_suffix="ac/l3/power",
unit="W",
groups=["string"],
)

# Grid voltages
grid12_voltage_sensor = SingleRegisterSensor(
"Grid L12 Voltage", 0x46, 0.1, mqtt_topic_suffix="ac/l12/voltage", unit="V", groups=["string"]
)
grid23_voltage_sensor = SingleRegisterSensor(
"Grid L23 Voltage", 0x47, 0.1, mqtt_topic_suffix="ac/l23/voltage", unit="V", groups=["string"]
)
grid31_voltage_sensor = SingleRegisterSensor(
"Grid L31 Voltage", 0x48, 0.1, mqtt_topic_suffix="ac/l31/voltage", unit="V", groups=["string"]
)

# Grid power
grid_power = DoubleRegisterSensor(
"Grid Power", 0xCB, 1.0, mqtt_topic_suffix="ac/grid/power", unit="W", groups=["string"]
)

# Load power
load_power = DoubleRegisterSensor(
"Load Power", 0xC6, 1.0, mqtt_topic_suffix="ac/ups/power", unit="W", groups=["string"]
)

# AC Freq
ac_freq_sensor = SingleRegisterSensor(
"AC Freq", 0x4F, 0.01, mqtt_topic_suffix="ac/freq", unit="Hz", groups=["string", "micro"]
Expand All @@ -92,6 +113,26 @@
"Uptime", 0x3E, 1, mqtt_topic_suffix="uptime", unit="minutes", groups=["string", "micro"]
)

# Totals
today_load_consumption_sensor = SingleRegisterSensor(
"Daily Load Consumption", 0xC8, 0.01, mqtt_topic_suffix="ac/ups/daily_energy", unit="kWh", groups=["string"]
)
total_load_consumption_sensor = DoubleRegisterSensor(
"Total Load Consumption", 0xC9, 0.1, mqtt_topic_suffix="ac/ups/total_energy", unit="kWh", groups=["string"]
)
today_energy_export_sensor = SingleRegisterSensor(
"Daily Energy Sold", 0xCD, 0.01, mqtt_topic_suffix="ac/daily_energy_sold", unit="kWh", groups=["string"]
)
total_energy_export_sensor = DoubleRegisterSensor(
"Total Energy Sold", 0xCE, 0.1, mqtt_topic_suffix="ac/total_energy_sold", unit="kWh", groups=["string"]
)
today_energy_import_sensor = SingleRegisterSensor(
"Daily Energy Bought", 0xD0, 0.01, mqtt_topic_suffix="ac/daily_energy_bought", unit="kWh", groups=["string"]
)
total_energy_import_sensor = DoubleRegisterSensor(
"Total Energy Bought", 0xD1, 0.1, mqtt_topic_suffix="ac/total_energy_bought", unit="kWh", groups=["string"]
)

# DC PV1
pv1_voltage_sensor = SingleRegisterSensor(
"PV1 Voltage", 0x6D, 0.1, mqtt_topic_suffix="dc/pv1/voltage", unit="V", groups=["string", "micro"]
Expand Down Expand Up @@ -231,8 +272,19 @@
phase3_voltage_sensor,
phase3_current_sensor,
phase3_power_sensor,
grid12_voltage_sensor,
grid23_voltage_sensor,
grid31_voltage_sensor,
grid_power,
load_power,
ac_freq_sensor,
uptime_sensor,
today_load_consumption_sensor,
total_load_consumption_sensor,
today_energy_export_sensor,
total_energy_export_sensor,
today_energy_import_sensor,
total_energy_import_sensor,
pv1_voltage_sensor,
pv1_current_sensor,
pv1_power_sensor,
Expand Down Expand Up @@ -275,6 +327,7 @@
sensor_register_ranges = (
[
SensorRegisterRange(group="string", first_reg_address=0x3C, last_reg_address=0x74),
SensorRegisterRange(group="string", first_reg_address=0xC6, last_reg_address=0xD2),
SensorRegisterRange(group="micro", first_reg_address=0x3C, last_reg_address=0x74),
]
+ deye_sg04lp3_register_ranges
Expand Down

0 comments on commit df875e9

Please sign in to comment.