Get faster updates for outputPower throught homePower from spaces & add yield & earning entitys
This commit is contained in:
parent
52b0e8c099
commit
9cefa395b7
@ -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
|
11
sensor.py
11
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},
|
||||
|
Loading…
x
Reference in New Issue
Block a user