Skip to content

Commit 4747993

Browse files
committed
Support current and voltage of up to 4 MPP trackers
1 parent 62c025f commit 4747993

File tree

4 files changed

+51
-11
lines changed

4 files changed

+51
-11
lines changed

homeassistant/components/fronius/icons.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"current_dc": {
55
"default": "mdi:current-dc"
66
},
7-
"current_dc_2": {
7+
"current_dc_mppt_no": {
88
"default": "mdi:current-dc"
99
},
1010
"voltage_dc": {
1111
"default": "mdi:current-dc"
1212
},
13-
"voltage_dc_2": {
13+
"voltage_dc_mppt_no": {
1414
"default": "mdi:current-dc"
1515
},
1616
"co2_factor": {

homeassistant/components/fronius/sensor.py

+41-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,26 @@ class FroniusSensorEntityDescription(SensorEntityDescription):
168168
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
169169
device_class=SensorDeviceClass.CURRENT,
170170
state_class=SensorStateClass.MEASUREMENT,
171+
translation_key="current_dc_mppt_no",
172+
translation_placeholders={"mppt_no": "2"},
173+
),
174+
FroniusSensorEntityDescription(
175+
key="current_dc_3",
176+
default_value=0,
177+
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
178+
device_class=SensorDeviceClass.CURRENT,
179+
state_class=SensorStateClass.MEASUREMENT,
180+
translation_key="current_dc_mppt_no",
181+
translation_placeholders={"mppt_no": "3"},
182+
),
183+
FroniusSensorEntityDescription(
184+
key="current_dc_4",
185+
default_value=0,
186+
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
187+
device_class=SensorDeviceClass.CURRENT,
188+
state_class=SensorStateClass.MEASUREMENT,
189+
translation_key="current_dc_mppt_no",
190+
translation_placeholders={"mppt_no": "4"},
171191
),
172192
FroniusSensorEntityDescription(
173193
key="power_ac",
@@ -197,6 +217,26 @@ class FroniusSensorEntityDescription(SensorEntityDescription):
197217
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
198218
device_class=SensorDeviceClass.VOLTAGE,
199219
state_class=SensorStateClass.MEASUREMENT,
220+
translation_key="voltage_dc_mppt_no",
221+
translation_placeholders={"mppt_no": "2"},
222+
),
223+
FroniusSensorEntityDescription(
224+
key="voltage_dc_3",
225+
default_value=0,
226+
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
227+
device_class=SensorDeviceClass.VOLTAGE,
228+
state_class=SensorStateClass.MEASUREMENT,
229+
translation_key="voltage_dc_mppt_no",
230+
translation_placeholders={"mppt_no": "3"},
231+
),
232+
FroniusSensorEntityDescription(
233+
key="voltage_dc_4",
234+
default_value=0,
235+
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
236+
device_class=SensorDeviceClass.VOLTAGE,
237+
state_class=SensorStateClass.MEASUREMENT,
238+
translation_key="voltage_dc_mppt_no",
239+
translation_placeholders={"mppt_no": "4"},
200240
),
201241
# device status entities
202242
FroniusSensorEntityDescription(
@@ -727,7 +767,7 @@ def __init__(
727767
self.response_key = description.response_key or description.key
728768
self.solar_net_id = solar_net_id
729769
self._attr_native_value = self._get_entity_value()
730-
self._attr_translation_key = description.key
770+
self._attr_translation_key = description.translation_key or description.key
731771

732772
def _device_data(self) -> dict[str, Any]:
733773
"""Extract information for SolarNet device from coordinator data."""

homeassistant/components/fronius/strings.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"current_dc": {
5353
"name": "DC current"
5454
},
55-
"current_dc_2": {
56-
"name": "DC current 2"
55+
"current_dc_mppt_no": {
56+
"name": "DC current {mppt_no}"
5757
},
5858
"power_ac": {
5959
"name": "AC power"
@@ -64,8 +64,8 @@
6464
"voltage_dc": {
6565
"name": "DC voltage"
6666
},
67-
"voltage_dc_2": {
68-
"name": "DC voltage 2"
67+
"voltage_dc_mppt_no": {
68+
"name": "DC voltage {mppt_no}"
6969
},
7070
"inverter_state": {
7171
"name": "Inverter state"

tests/components/fronius/snapshots/test_sensor.ambr

+4-4
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
'platform': 'fronius',
239239
'previous_unique_id': None,
240240
'supported_features': 0,
241-
'translation_key': 'current_dc_2',
241+
'translation_key': 'current_dc_mppt_no',
242242
'unique_id': '12345678-current_dc_2',
243243
'unit_of_measurement': <UnitOfElectricCurrent.AMPERE: 'A'>,
244244
})
@@ -342,7 +342,7 @@
342342
'platform': 'fronius',
343343
'previous_unique_id': None,
344344
'supported_features': 0,
345-
'translation_key': 'voltage_dc_2',
345+
'translation_key': 'voltage_dc_mppt_no',
346346
'unique_id': '12345678-voltage_dc_2',
347347
'unit_of_measurement': <UnitOfElectricPotential.VOLT: 'V'>,
348348
})
@@ -3798,7 +3798,7 @@
37983798
'platform': 'fronius',
37993799
'previous_unique_id': None,
38003800
'supported_features': 0,
3801-
'translation_key': 'current_dc_2',
3801+
'translation_key': 'current_dc_mppt_no',
38023802
'unique_id': '12345678-current_dc_2',
38033803
'unit_of_measurement': <UnitOfElectricCurrent.AMPERE: 'A'>,
38043804
})
@@ -3902,7 +3902,7 @@
39023902
'platform': 'fronius',
39033903
'previous_unique_id': None,
39043904
'supported_features': 0,
3905-
'translation_key': 'voltage_dc_2',
3905+
'translation_key': 'voltage_dc_mppt_no',
39063906
'unique_id': '12345678-voltage_dc_2',
39073907
'unit_of_measurement': <UnitOfElectricPotential.VOLT: 'V'>,
39083908
})

0 commit comments

Comments
 (0)