From 9cefa395b7f008ab06c0ffd1f1574a96dc9eb933 Mon Sep 17 00:00:00 2001 From: Simon Zeyer Date: Thu, 5 Jun 2025 15:22:43 +0000 Subject: [PATCH] Get faster updates for outputPower throught homePower from spaces & add yield & earning entitys --- helper.py | 2 ++ sensor.py | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/helper.py b/helper.py index 0a8d716..00857a9 100644 --- a/helper.py +++ b/helper.py @@ -13,5 +13,7 @@ def get_merged_device_data(coordinator): if device["deviceType"] == "ENERGY_STORAGE_BATTERY": space = family["spaces"].get(device["spaceId"], {}) device = {**device, **space.get("battery",{})} # Merge statistics into device + device = {**device, **space.get("today", {})} # Merge earnings into device + device["outputPower"] = device.get("homePower", 0) # homePower is outputPower but refreshed faster ret[family['id']]['devices'][device['deviceId']] = device return ret \ No newline at end of file diff --git a/sensor.py b/sensor.py index bfc4fa2..710e322 100644 --- a/sensor.py +++ b/sensor.py @@ -12,15 +12,16 @@ async def async_setup_entry(hass, entry, async_add_entities): for family_key in data: family = data[family_key] - if "devices" not in family: - continue + + + # Geräteinformationen for device_key in family["devices"]: device = family["devices"][device_key] device_info = DeviceInfo( identifiers={(DOMAIN, device["deviceId"], device.get("deviceSn",""))}, name=device.get("stationName", "Unbekanntes Gerät"), serial_number=device.get("deviceSn", "Unbekannt"), - suggested_area=family.get("name", "Unbekannt"), + suggested_area=family.get("name", None), manufacturer="Sunlit Solar", model=device.get("deviceType", "Unbekanntes Modell"), ) @@ -29,7 +30,7 @@ async def async_setup_entry(hass, entry, async_add_entities): identifiers={(DOMAIN, device["deviceId"], device.get("deviceSn",""))}, name="Speicher", serial_number=device.get("deviceSn", "Unbekannt"), - suggested_area=family.get("name", "Unbekannt"), + suggested_area=family.get("name", None), manufacturer="Sunlit Solar", model=device.get("deviceType", "Unbekanntes Modell"), ) @@ -43,6 +44,8 @@ async def async_setup_entry(hass, entry, async_add_entities): {'id': 'inputPower', 'name': 'Eingangsleistung', 'device_class': "power", 'state_class': "measurement", 'native_unit_of_measurement': "W"}, {'id': 'outputPower', 'name': 'Ausgangsleistung', 'device_class': "power", 'state_class': "measurement", 'native_unit_of_measurement': "W"}, {'id': 'firmwareVersion', 'name': 'Firmware-Version', 'device_class': None, 'state_class': None, 'native_unit_of_measurement': None}, + {'id': 'yield', 'name': 'Ertrag', 'device_class': "energy", 'state_class': "measurement", 'native_unit_of_measurement': "kWh"}, + {'id': 'earning', 'name': 'Einnahmen', 'device_class': "monetary", 'state_class': "measurement", 'native_unit_of_measurement': "EUR"}, # {'id': 'status', 'name': 'Status', 'value': device.get('status', 'Unbekannt'), 'device_class': None, 'state_class': None, 'native_unit_of_measurement': None}, # {'id': 'status', 'name': 'Status', 'value': device.get('status', 'Unbekannt'), 'device_class': None, 'state_class': None, 'native_unit_of_measurement': None}, # {'id': 'status', 'name': 'Status', 'value': device.get('status', 'Unbekannt'), 'device_class': None, 'state_class': None, 'native_unit_of_measurement': None},