Skip to content

Commit df2cbdb

Browse files
committed
Fix localization
1 parent 2e7f585 commit df2cbdb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

custom_components/pylontech_serial/sensor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class PylontechSystemSensor(CoordinatorEntity, SensorEntity):
124124

125125
def __init__(self, coordinator, unique_id_prefix, key, unit, device_class, attr_name, state_class=None, entity_category=None):
126126
super().__init__(coordinator)
127-
self._attr_name = attr_name # field name in struct
127+
self._attribute_key = attr_name # field name in struct
128128
self._unit = unit
129129
self._device_class = device_class
130130
self._attr_state_class = state_class
@@ -144,7 +144,7 @@ def __init__(self, coordinator, unique_id_prefix, key, unit, device_class, attr_
144144
@property
145145
def native_value(self):
146146
if not self.coordinator.data: return None
147-
return getattr(self.coordinator.data, self._attr_name, None)
147+
return getattr(self.coordinator.data, self._attribute_key, None)
148148

149149
@property
150150
def native_unit_of_measurement(self):
@@ -171,7 +171,7 @@ class PylontechBatterySensor(CoordinatorEntity, SensorEntity):
171171
def __init__(self, coordinator, unique_id_prefix, bat_id, suffix, unit, device_class, attr_name, entity_category=None):
172172
super().__init__(coordinator)
173173
self._bat_id = bat_id
174-
self._attr_name = attr_name
174+
self._attribute_key = attr_name
175175
self._unit = unit
176176
self._device_class = device_class
177177
self._attr_entity_category = entity_category
@@ -192,7 +192,7 @@ def native_value(self):
192192
if not self.coordinator.data: return None
193193
for b in self.coordinator.data.batteries:
194194
if b.sys_id == self._bat_id:
195-
return getattr(b, self._attr_name, None)
195+
return getattr(b, self._attribute_key, None)
196196
return None
197197

198198
@property

0 commit comments

Comments
 (0)