Skip to content

Commit 354055a

Browse files
authored
Merge pull request #100 from RustyDust/sru_work
Add sensor for `battery_care`, fix oversight in relation to new mode 11
2 parents 6eb4fcb + b4e7705 commit 354055a

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

custom_components/sonnenbatterie/coordinator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
1010
from sonnenbatterie import AsyncSonnenBatterie
1111

12-
from custom_components.sonnenbatterie import LOGGER, DOMAIN, ATTR_SONNEN_DEBUG, CONF_SERIAL_NUMBER
12+
from custom_components.sonnenbatterie import LOGGER, DOMAIN, ATTR_SONNEN_DEBUG
1313

1414

1515
class SonnenbatterieCoordinator(DataUpdateCoordinator):
@@ -87,6 +87,7 @@ def populate_battery_info(self):
8787
async def _async_update_data(self):
8888
"""Populate self.latestdata"""
8989
if time() - self._last_login > 60:
90+
# noinspection PyBroadException
9091
try:
9192
await self.sbconn.logout()
9293
except:
@@ -123,6 +124,9 @@ async def _async_update_data(self):
123124
result = await self.sbconn.get_commissioning_settings()
124125
self.latestData["commissioning_settings"] = result
125126

127+
result = await self.sbconn.sb2.get_status()
128+
self.latestData["v2_status"] = result
129+
126130
self._last_error = None
127131

128132
except Exception as e:

custom_components/sonnenbatterie/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"iot_class": "local_polling",
99
"issue_tracker": "https://github.com/weltmeyer/ha_sonnenbatterie/issues",
1010
"requirements": ["requests","sonnenbatterie>=0.6.0"],
11-
"version": "2025.03.01"
11+
"version": "2025.03.02"
1212
}

custom_components/sonnenbatterie/sensor_list.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def generate_powermeter_sensors(_coordinator):
288288
key="state_operating_mode",
289289
legacy_key="operating_mode",
290290
icon="mdi:state-machine",
291-
options=["1", "2", "6", "10"],
291+
options=["1", "2", "6", "10", "11"],
292292
device_class=SensorDeviceClass.ENUM,
293293
value_fn=lambda coordinator: coordinator.latestData.get("status", {}).get(
294294
"OperatingMode"
@@ -546,5 +546,14 @@ def generate_powermeter_sensors(_coordinator):
546546
value_fn=lambda coordinator: coordinator.latestData.get("commissioning_settings", {})
547547
.get('data', {}).get('attributes',{}).get('tou_max_power_limit', 'unknown'),
548548
entity_registry_enabled_default=True,
549+
),
550+
SonnenbatterieSensorEntityDescription(
551+
key="battery_care",
552+
icon="mdi:wrench-clock",
553+
state_class=SensorStateClass.MEASUREMENT,
554+
entity_category=EntityCategory.DIAGNOSTIC,
555+
value_fn=lambda coordinator: (coordinator.latestData.get("v2_status", {})
556+
.get("dischargeNotAllowed", "false") == "true"),
557+
entity_registry_enabled_default=True,
549558
)
550559
)

custom_components/sonnenbatterie/translations/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@
185185
},
186186
"tou_max_power": {
187187
"name": "Maximaler ToU Netzbezug"
188+
},
189+
"battery_care": {
190+
"name": "Batteriepflege aktiv"
188191
}
189192
}
190193
},

custom_components/sonnenbatterie/translations/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@
186186
},
187187
"tou_max_power": {
188188
"name": "ToU max power consumption"
189+
},
190+
"battery_care": {
191+
"name": "Battery care active"
189192
}
190193
}
191194
},

0 commit comments

Comments
 (0)