mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Fix sensor displaying unknown when getting readings from heat meters in ista EcoTrend (#147741)
This commit is contained in:
parent
d8c7ed473b
commit
9961a499ee
@ -108,22 +108,22 @@ def get_statistics(
|
||||
if monthly_consumptions := get_consumptions(data, value_type):
|
||||
return [
|
||||
{
|
||||
"value": as_number(
|
||||
get_values_by_type(
|
||||
consumptions=consumptions,
|
||||
consumption_type=consumption_type,
|
||||
).get(
|
||||
"additionalValue"
|
||||
if value_type == IstaValueType.ENERGY
|
||||
else "value"
|
||||
)
|
||||
),
|
||||
"value": as_number(value),
|
||||
"date": consumptions["date"],
|
||||
}
|
||||
for consumptions in monthly_consumptions
|
||||
if get_values_by_type(
|
||||
consumptions=consumptions,
|
||||
consumption_type=consumption_type,
|
||||
).get("additionalValue" if value_type == IstaValueType.ENERGY else "value")
|
||||
if (
|
||||
value := (
|
||||
consumption := get_values_by_type(
|
||||
consumptions=consumptions,
|
||||
consumption_type=consumption_type,
|
||||
)
|
||||
).get(
|
||||
"additionalValue"
|
||||
if value_type == IstaValueType.ENERGY
|
||||
and consumption.get("additionalValue") is not None
|
||||
else "value"
|
||||
)
|
||||
)
|
||||
]
|
||||
return None
|
||||
|
@ -96,12 +96,16 @@ def get_consumption_data(obj_uuid: str | None = None) -> dict[str, Any]:
|
||||
{
|
||||
"type": "heating",
|
||||
"value": "35",
|
||||
"unit": "Einheiten",
|
||||
"additionalValue": "38,0",
|
||||
"additionalUnit": "kWh",
|
||||
},
|
||||
{
|
||||
"type": "warmwater",
|
||||
"value": "1,0",
|
||||
"unit": "m³",
|
||||
"additionalValue": "57,0",
|
||||
"additionalUnit": "kWh",
|
||||
},
|
||||
{
|
||||
"type": "water",
|
||||
@ -115,16 +119,21 @@ def get_consumption_data(obj_uuid: str | None = None) -> dict[str, Any]:
|
||||
{
|
||||
"type": "heating",
|
||||
"value": "104",
|
||||
"unit": "Einheiten",
|
||||
"additionalValue": "113,0",
|
||||
"additionalUnit": "kWh",
|
||||
},
|
||||
{
|
||||
"type": "warmwater",
|
||||
"value": "1,1",
|
||||
"unit": "m³",
|
||||
"additionalValue": "61,1",
|
||||
"additionalUnit": "kWh",
|
||||
},
|
||||
{
|
||||
"type": "water",
|
||||
"value": "6,8",
|
||||
"unit": "m³",
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -200,16 +209,21 @@ def extend_statistics(obj_uuid: str | None = None) -> dict[str, Any]:
|
||||
{
|
||||
"type": "heating",
|
||||
"value": "9000",
|
||||
"unit": "Einheiten",
|
||||
"additionalValue": "9000,0",
|
||||
"additionalUnit": "kWh",
|
||||
},
|
||||
{
|
||||
"type": "warmwater",
|
||||
"value": "9999,0",
|
||||
"unit": "m³",
|
||||
"additionalValue": "90000,0",
|
||||
"additionalUnit": "kWh",
|
||||
},
|
||||
{
|
||||
"type": "water",
|
||||
"value": "9000,0",
|
||||
"unit": "m³",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -12,13 +12,17 @@
|
||||
}),
|
||||
'readings': list([
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '38,0',
|
||||
'type': 'heating',
|
||||
'unit': 'Einheiten',
|
||||
'value': '35',
|
||||
}),
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '57,0',
|
||||
'type': 'warmwater',
|
||||
'unit': 'm³',
|
||||
'value': '1,0',
|
||||
}),
|
||||
dict({
|
||||
@ -34,17 +38,22 @@
|
||||
}),
|
||||
'readings': list([
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '113,0',
|
||||
'type': 'heating',
|
||||
'unit': 'Einheiten',
|
||||
'value': '104',
|
||||
}),
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '61,1',
|
||||
'type': 'warmwater',
|
||||
'unit': 'm³',
|
||||
'value': '1,1',
|
||||
}),
|
||||
dict({
|
||||
'type': 'water',
|
||||
'unit': 'm³',
|
||||
'value': '6,8',
|
||||
}),
|
||||
]),
|
||||
@ -103,13 +112,17 @@
|
||||
}),
|
||||
'readings': list([
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '38,0',
|
||||
'type': 'heating',
|
||||
'unit': 'Einheiten',
|
||||
'value': '35',
|
||||
}),
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '57,0',
|
||||
'type': 'warmwater',
|
||||
'unit': 'm³',
|
||||
'value': '1,0',
|
||||
}),
|
||||
dict({
|
||||
@ -125,17 +138,22 @@
|
||||
}),
|
||||
'readings': list([
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '113,0',
|
||||
'type': 'heating',
|
||||
'unit': 'Einheiten',
|
||||
'value': '104',
|
||||
}),
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '61,1',
|
||||
'type': 'warmwater',
|
||||
'unit': 'm³',
|
||||
'value': '1,1',
|
||||
}),
|
||||
dict({
|
||||
'type': 'water',
|
||||
'unit': 'm³',
|
||||
'value': '6,8',
|
||||
}),
|
||||
]),
|
||||
|
@ -97,12 +97,22 @@
|
||||
# ---
|
||||
# name: test_get_statistics[water-energy]
|
||||
list([
|
||||
dict({
|
||||
'date': datetime.datetime(2024, 4, 30, 0, 0, tzinfo=datetime.timezone.utc),
|
||||
'value': 6.8,
|
||||
}),
|
||||
dict({
|
||||
'date': datetime.datetime(2024, 5, 31, 0, 0, tzinfo=datetime.timezone.utc),
|
||||
'value': 5.0,
|
||||
}),
|
||||
])
|
||||
# ---
|
||||
# name: test_get_values_by_type[heating]
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '38,0',
|
||||
'type': 'heating',
|
||||
'unit': 'Einheiten',
|
||||
'value': '35',
|
||||
})
|
||||
# ---
|
||||
@ -114,8 +124,10 @@
|
||||
# ---
|
||||
# name: test_get_values_by_type[warmwater]
|
||||
dict({
|
||||
'additionalUnit': 'kWh',
|
||||
'additionalValue': '57,0',
|
||||
'type': 'warmwater',
|
||||
'unit': 'm³',
|
||||
'value': '1,0',
|
||||
})
|
||||
# ---
|
||||
@ -128,6 +140,7 @@
|
||||
# name: test_get_values_by_type[water]
|
||||
dict({
|
||||
'type': 'water',
|
||||
'unit': 'm³',
|
||||
'value': '5,0',
|
||||
})
|
||||
# ---
|
||||
|
@ -52,16 +52,21 @@ def test_get_values_by_type(
|
||||
{
|
||||
"type": "heating",
|
||||
"value": "35",
|
||||
"unit": "Einheiten",
|
||||
"additionalValue": "38,0",
|
||||
"additionalUnit": "kWh",
|
||||
},
|
||||
{
|
||||
"type": "warmwater",
|
||||
"value": "1,0",
|
||||
"unit": "m³",
|
||||
"additionalValue": "57,0",
|
||||
"additionalUnit": "kWh",
|
||||
},
|
||||
{
|
||||
"type": "water",
|
||||
"value": "5,0",
|
||||
"unit": "m³",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user