diff --git a/custom_components/sonnenbatterie/__init__.py b/custom_components/sonnenbatterie/__init__.py index 6d23a87..eb9a50d 100644 --- a/custom_components/sonnenbatterie/__init__.py +++ b/custom_components/sonnenbatterie/__init__.py @@ -206,6 +206,25 @@ async def get_tou_schedule(call: ServiceCall) -> ServiceResponse: "schedule": response, } + # noinspection PyUnusedLocal + async def get_battery_reserve(call: ServiceCall) -> ServiceResponse: + sb_conn = _get_sb_connection(call.data) + await sb_conn.login() + response = await sb_conn.sb2.get_battery_reserve() + await sb_conn.logout() + return { + "backup_reserve": response, + } + + async def get_operating_mode(call: ServiceCall) -> ServiceResponse: + sb_conn = _get_sb_connection(call.data) + await sb_conn.login() + response = await sb_conn.sb2.get_operating_mode() + await sb_conn.logout() + return { + "operating_mode": response, + } + # service registration hass.services.async_register( DOMAIN, @@ -262,6 +281,20 @@ async def get_tou_schedule(call: ServiceCall) -> ServiceResponse: supports_response=SupportsResponse.ONLY, ) + hass.services.async_register( + DOMAIN, + "get_battery_reserve", + get_battery_reserve, + supports_response=SupportsResponse.ONLY, + ) + + hass.services.async_register( + DOMAIN, + "get_operating_mode", + get_operating_mode, + supports_response=SupportsResponse.ONLY, + ) + # Done setting up the entry return True diff --git a/custom_components/sonnenbatterie/services.yaml b/custom_components/sonnenbatterie/services.yaml index 99cb357..1ff6d88 100644 --- a/custom_components/sonnenbatterie/services.yaml +++ b/custom_components/sonnenbatterie/services.yaml @@ -84,3 +84,17 @@ get_tou_schedule: selector: device: integration: sonnenbatterie +get_battery_reserve: + fields: + device_id: + required: true + selector: + device: + integration: sonnenbatterie +get_operating_mode: + fields: + device_id: + required: true + selector: + device: + integration: sonnenbatterie diff --git a/custom_components/sonnenbatterie/translations/de.json b/custom_components/sonnenbatterie/translations/de.json index 01d21e3..a357219 100644 --- a/custom_components/sonnenbatterie/translations/de.json +++ b/custom_components/sonnenbatterie/translations/de.json @@ -262,6 +262,28 @@ "example": "1234567890" } } + }, + "get_battery_reserve": { + "name": "Auslesen der Batterie-Reserve", + "description": "Liefert die von der Sonnebatterie als Reserve zurückgehaltene Kapazität in Prozent", + "fields": { + "device_id": { + "description": "HomeAssistant ID des Geräts", + "name": "Device ID", + "example": "1234567890" + } + } + }, + "get_operating_mode": { + "name": "Betriebsmodus auslesen", + "description": "Liefert den aktuellen Betriebsmodus der Sonnebatterie in numerischer Form", + "fields": { + "device_id": { + "description": "HomeAssistant ID des Geräts", + "name": "Device ID", + "example": "1234567890" + } + } } } } diff --git a/custom_components/sonnenbatterie/translations/en.json b/custom_components/sonnenbatterie/translations/en.json index dc9d107..a90eeac 100644 --- a/custom_components/sonnenbatterie/translations/en.json +++ b/custom_components/sonnenbatterie/translations/en.json @@ -262,6 +262,28 @@ "example": "1234567890" } } + }, + "get_battery_reserve": { + "name": "Get battery reserve", + "description": "Returns the percentage of capacity the Sonnebatterie keeps back.", + "fields": { + "device_id": { + "description": "HomeAssistant ID of the target device", + "name": "Device ID", + "example": "1234567890" + } + } + }, + "get_operating_mode": { + "name": "Get operating mode", + "description": "Returns the current operating mode of the SonnenBatterie in numeric form", + "fields": { + "device_id": { + "description": "HomeAssistant ID of the target device", + "name": "Device ID", + "example": "1234567890" + } + } } - } +} }