mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +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):
|
if monthly_consumptions := get_consumptions(data, value_type):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"value": as_number(
|
"value": as_number(value),
|
||||||
get_values_by_type(
|
|
||||||
consumptions=consumptions,
|
|
||||||
consumption_type=consumption_type,
|
|
||||||
).get(
|
|
||||||
"additionalValue"
|
|
||||||
if value_type == IstaValueType.ENERGY
|
|
||||||
else "value"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"date": consumptions["date"],
|
"date": consumptions["date"],
|
||||||
}
|
}
|
||||||
for consumptions in monthly_consumptions
|
for consumptions in monthly_consumptions
|
||||||
if get_values_by_type(
|
if (
|
||||||
consumptions=consumptions,
|
value := (
|
||||||
consumption_type=consumption_type,
|
consumption := get_values_by_type(
|
||||||
).get("additionalValue" if value_type == IstaValueType.ENERGY else "value")
|
consumptions=consumptions,
|
||||||
|
consumption_type=consumption_type,
|
||||||
|
)
|
||||||
|
).get(
|
||||||
|
"additionalValue"
|
||||||
|
if value_type == IstaValueType.ENERGY
|
||||||
|
and consumption.get("additionalValue") is not None
|
||||||
|
else "value"
|
||||||
|
)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
return None
|
return None
|
||||||
|
@ -96,12 +96,16 @@ def get_consumption_data(obj_uuid: str | None = None) -> dict[str, Any]:
|
|||||||
{
|
{
|
||||||
"type": "heating",
|
"type": "heating",
|
||||||
"value": "35",
|
"value": "35",
|
||||||
|
"unit": "Einheiten",
|
||||||
"additionalValue": "38,0",
|
"additionalValue": "38,0",
|
||||||
|
"additionalUnit": "kWh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "warmwater",
|
"type": "warmwater",
|
||||||
"value": "1,0",
|
"value": "1,0",
|
||||||
|
"unit": "m³",
|
||||||
"additionalValue": "57,0",
|
"additionalValue": "57,0",
|
||||||
|
"additionalUnit": "kWh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "water",
|
"type": "water",
|
||||||
@ -115,16 +119,21 @@ def get_consumption_data(obj_uuid: str | None = None) -> dict[str, Any]:
|
|||||||
{
|
{
|
||||||
"type": "heating",
|
"type": "heating",
|
||||||
"value": "104",
|
"value": "104",
|
||||||
|
"unit": "Einheiten",
|
||||||
"additionalValue": "113,0",
|
"additionalValue": "113,0",
|
||||||
|
"additionalUnit": "kWh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "warmwater",
|
"type": "warmwater",
|
||||||
"value": "1,1",
|
"value": "1,1",
|
||||||
|
"unit": "m³",
|
||||||
"additionalValue": "61,1",
|
"additionalValue": "61,1",
|
||||||
|
"additionalUnit": "kWh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "water",
|
"type": "water",
|
||||||
"value": "6,8",
|
"value": "6,8",
|
||||||
|
"unit": "m³",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -200,16 +209,21 @@ def extend_statistics(obj_uuid: str | None = None) -> dict[str, Any]:
|
|||||||
{
|
{
|
||||||
"type": "heating",
|
"type": "heating",
|
||||||
"value": "9000",
|
"value": "9000",
|
||||||
|
"unit": "Einheiten",
|
||||||
"additionalValue": "9000,0",
|
"additionalValue": "9000,0",
|
||||||
|
"additionalUnit": "kWh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "warmwater",
|
"type": "warmwater",
|
||||||
"value": "9999,0",
|
"value": "9999,0",
|
||||||
|
"unit": "m³",
|
||||||
"additionalValue": "90000,0",
|
"additionalValue": "90000,0",
|
||||||
|
"additionalUnit": "kWh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "water",
|
"type": "water",
|
||||||
"value": "9000,0",
|
"value": "9000,0",
|
||||||
|
"unit": "m³",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -12,13 +12,17 @@
|
|||||||
}),
|
}),
|
||||||
'readings': list([
|
'readings': list([
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '38,0',
|
'additionalValue': '38,0',
|
||||||
'type': 'heating',
|
'type': 'heating',
|
||||||
|
'unit': 'Einheiten',
|
||||||
'value': '35',
|
'value': '35',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '57,0',
|
'additionalValue': '57,0',
|
||||||
'type': 'warmwater',
|
'type': 'warmwater',
|
||||||
|
'unit': 'm³',
|
||||||
'value': '1,0',
|
'value': '1,0',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
@ -34,17 +38,22 @@
|
|||||||
}),
|
}),
|
||||||
'readings': list([
|
'readings': list([
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '113,0',
|
'additionalValue': '113,0',
|
||||||
'type': 'heating',
|
'type': 'heating',
|
||||||
|
'unit': 'Einheiten',
|
||||||
'value': '104',
|
'value': '104',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '61,1',
|
'additionalValue': '61,1',
|
||||||
'type': 'warmwater',
|
'type': 'warmwater',
|
||||||
|
'unit': 'm³',
|
||||||
'value': '1,1',
|
'value': '1,1',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
'type': 'water',
|
'type': 'water',
|
||||||
|
'unit': 'm³',
|
||||||
'value': '6,8',
|
'value': '6,8',
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
@ -103,13 +112,17 @@
|
|||||||
}),
|
}),
|
||||||
'readings': list([
|
'readings': list([
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '38,0',
|
'additionalValue': '38,0',
|
||||||
'type': 'heating',
|
'type': 'heating',
|
||||||
|
'unit': 'Einheiten',
|
||||||
'value': '35',
|
'value': '35',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '57,0',
|
'additionalValue': '57,0',
|
||||||
'type': 'warmwater',
|
'type': 'warmwater',
|
||||||
|
'unit': 'm³',
|
||||||
'value': '1,0',
|
'value': '1,0',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
@ -125,17 +138,22 @@
|
|||||||
}),
|
}),
|
||||||
'readings': list([
|
'readings': list([
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '113,0',
|
'additionalValue': '113,0',
|
||||||
'type': 'heating',
|
'type': 'heating',
|
||||||
|
'unit': 'Einheiten',
|
||||||
'value': '104',
|
'value': '104',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '61,1',
|
'additionalValue': '61,1',
|
||||||
'type': 'warmwater',
|
'type': 'warmwater',
|
||||||
|
'unit': 'm³',
|
||||||
'value': '1,1',
|
'value': '1,1',
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
'type': 'water',
|
'type': 'water',
|
||||||
|
'unit': 'm³',
|
||||||
'value': '6,8',
|
'value': '6,8',
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
|
@ -97,12 +97,22 @@
|
|||||||
# ---
|
# ---
|
||||||
# name: test_get_statistics[water-energy]
|
# name: test_get_statistics[water-energy]
|
||||||
list([
|
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]
|
# name: test_get_values_by_type[heating]
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '38,0',
|
'additionalValue': '38,0',
|
||||||
'type': 'heating',
|
'type': 'heating',
|
||||||
|
'unit': 'Einheiten',
|
||||||
'value': '35',
|
'value': '35',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
@ -114,8 +124,10 @@
|
|||||||
# ---
|
# ---
|
||||||
# name: test_get_values_by_type[warmwater]
|
# name: test_get_values_by_type[warmwater]
|
||||||
dict({
|
dict({
|
||||||
|
'additionalUnit': 'kWh',
|
||||||
'additionalValue': '57,0',
|
'additionalValue': '57,0',
|
||||||
'type': 'warmwater',
|
'type': 'warmwater',
|
||||||
|
'unit': 'm³',
|
||||||
'value': '1,0',
|
'value': '1,0',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
@ -128,6 +140,7 @@
|
|||||||
# name: test_get_values_by_type[water]
|
# name: test_get_values_by_type[water]
|
||||||
dict({
|
dict({
|
||||||
'type': 'water',
|
'type': 'water',
|
||||||
|
'unit': 'm³',
|
||||||
'value': '5,0',
|
'value': '5,0',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
@ -52,16 +52,21 @@ def test_get_values_by_type(
|
|||||||
{
|
{
|
||||||
"type": "heating",
|
"type": "heating",
|
||||||
"value": "35",
|
"value": "35",
|
||||||
|
"unit": "Einheiten",
|
||||||
"additionalValue": "38,0",
|
"additionalValue": "38,0",
|
||||||
|
"additionalUnit": "kWh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "warmwater",
|
"type": "warmwater",
|
||||||
"value": "1,0",
|
"value": "1,0",
|
||||||
|
"unit": "m³",
|
||||||
"additionalValue": "57,0",
|
"additionalValue": "57,0",
|
||||||
|
"additionalUnit": "kWh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "water",
|
"type": "water",
|
||||||
"value": "5,0",
|
"value": "5,0",
|
||||||
|
"unit": "m³",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user