mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add peak usage sensors to dsmr (#102227)
This commit is contained in:
parent
a187164bf8
commit
da653c36fd
@ -356,6 +356,22 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
|
DSMRSensorEntityDescription(
|
||||||
|
key="belgium_current_average_demand",
|
||||||
|
translation_key="current_average_demand",
|
||||||
|
obis_reference=obis_references.BELGIUM_CURRENT_AVERAGE_DEMAND,
|
||||||
|
dsmr_versions={"5B"},
|
||||||
|
force_update=True,
|
||||||
|
device_class=SensorDeviceClass.POWER,
|
||||||
|
),
|
||||||
|
DSMRSensorEntityDescription(
|
||||||
|
key="belgium_maximum_demand_current_month",
|
||||||
|
translation_key="maximum_demand_current_month",
|
||||||
|
obis_reference=obis_references.BELGIUM_MAXIMUM_DEMAND_MONTH,
|
||||||
|
dsmr_versions={"5B"},
|
||||||
|
force_update=True,
|
||||||
|
device_class=SensorDeviceClass.POWER,
|
||||||
|
),
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="hourly_gas_meter_reading",
|
key="hourly_gas_meter_reading",
|
||||||
translation_key="gas_meter_reading",
|
translation_key="gas_meter_reading",
|
||||||
|
@ -76,6 +76,12 @@
|
|||||||
"gas_meter_reading": {
|
"gas_meter_reading": {
|
||||||
"name": "Gas consumption"
|
"name": "Gas consumption"
|
||||||
},
|
},
|
||||||
|
"current_average_demand": {
|
||||||
|
"name": "Current average demand"
|
||||||
|
},
|
||||||
|
"maximum_demand_current_month": {
|
||||||
|
"name": "Maximum demand current month"
|
||||||
|
},
|
||||||
"instantaneous_active_power_l1_negative": {
|
"instantaneous_active_power_l1_negative": {
|
||||||
"name": "Power production phase L1"
|
"name": "Power production phase L1"
|
||||||
},
|
},
|
||||||
|
@ -480,7 +480,11 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No
|
|||||||
"""Test if Belgian meter is correctly parsed."""
|
"""Test if Belgian meter is correctly parsed."""
|
||||||
(connection_factory, transport, protocol) = dsmr_connection_fixture
|
(connection_factory, transport, protocol) = dsmr_connection_fixture
|
||||||
|
|
||||||
from dsmr_parser.obis_references import ELECTRICITY_ACTIVE_TARIFF
|
from dsmr_parser.obis_references import (
|
||||||
|
BELGIUM_CURRENT_AVERAGE_DEMAND,
|
||||||
|
BELGIUM_MAXIMUM_DEMAND_MONTH,
|
||||||
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
|
)
|
||||||
from dsmr_parser.objects import CosemObject, MBusObject
|
from dsmr_parser.objects import CosemObject, MBusObject
|
||||||
|
|
||||||
entry_data = {
|
entry_data = {
|
||||||
@ -503,6 +507,17 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No
|
|||||||
{"value": Decimal(745.695), "unit": "m3"},
|
{"value": Decimal(745.695), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
BELGIUM_CURRENT_AVERAGE_DEMAND: CosemObject(
|
||||||
|
BELGIUM_CURRENT_AVERAGE_DEMAND,
|
||||||
|
[{"value": Decimal(1.75), "unit": "kW"}],
|
||||||
|
),
|
||||||
|
BELGIUM_MAXIMUM_DEMAND_MONTH: MBusObject(
|
||||||
|
BELGIUM_MAXIMUM_DEMAND_MONTH,
|
||||||
|
[
|
||||||
|
{"value": datetime.datetime.fromtimestamp(1551642218)},
|
||||||
|
{"value": Decimal(4.11), "unit": "kW"},
|
||||||
|
],
|
||||||
|
),
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
||||||
),
|
),
|
||||||
@ -534,6 +549,20 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No
|
|||||||
assert active_tariff.attributes.get(ATTR_STATE_CLASS) is None
|
assert active_tariff.attributes.get(ATTR_STATE_CLASS) is None
|
||||||
assert active_tariff.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
assert active_tariff.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||||
|
|
||||||
|
# check current average demand is parsed correctly
|
||||||
|
avg_demand = hass.states.get("sensor.electricity_meter_current_average_demand")
|
||||||
|
assert avg_demand.state == "1.75"
|
||||||
|
assert avg_demand.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.KILO_WATT
|
||||||
|
assert avg_demand.attributes.get(ATTR_STATE_CLASS) is None
|
||||||
|
|
||||||
|
# check max average demand is parsed correctly
|
||||||
|
max_demand = hass.states.get(
|
||||||
|
"sensor.electricity_meter_maximum_demand_current_month"
|
||||||
|
)
|
||||||
|
assert max_demand.state == "4.11"
|
||||||
|
assert max_demand.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.KILO_WATT
|
||||||
|
assert max_demand.attributes.get(ATTR_STATE_CLASS) is None
|
||||||
|
|
||||||
# check if gas consumption is parsed correctly
|
# check if gas consumption is parsed correctly
|
||||||
gas_consumption = hass.states.get("sensor.gas_meter_gas_consumption")
|
gas_consumption = hass.states.get("sensor.gas_meter_gas_consumption")
|
||||||
assert gas_consumption.state == "745.695"
|
assert gas_consumption.state == "745.695"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user