mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Correct deprecated telegram usage in dsmr (#121847)
This commit is contained in:
parent
244af091b8
commit
a0d0e0f4a9
@ -16,7 +16,7 @@ from dsmr_parser.clients.rfxtrx_protocol import (
|
|||||||
create_rfxtrx_dsmr_reader,
|
create_rfxtrx_dsmr_reader,
|
||||||
create_rfxtrx_tcp_dsmr_reader,
|
create_rfxtrx_tcp_dsmr_reader,
|
||||||
)
|
)
|
||||||
from dsmr_parser.objects import DSMRObject
|
from dsmr_parser.objects import DSMRObject, Telegram
|
||||||
import serial
|
import serial
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
@ -380,7 +380,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
|||||||
|
|
||||||
|
|
||||||
def create_mbus_entity(
|
def create_mbus_entity(
|
||||||
mbus: int, mtype: int, telegram: dict[str, DSMRObject]
|
mbus: int, mtype: int, telegram: Telegram
|
||||||
) -> DSMRSensorEntityDescription | None:
|
) -> DSMRSensorEntityDescription | None:
|
||||||
"""Create a new MBUS Entity."""
|
"""Create a new MBUS Entity."""
|
||||||
if (
|
if (
|
||||||
@ -478,7 +478,7 @@ def rename_old_gas_to_mbus(
|
|||||||
|
|
||||||
|
|
||||||
def create_mbus_entities(
|
def create_mbus_entities(
|
||||||
hass: HomeAssistant, telegram: dict[str, DSMRObject], entry: ConfigEntry
|
hass: HomeAssistant, telegram: Telegram, entry: ConfigEntry
|
||||||
) -> list[DSMREntity]:
|
) -> list[DSMREntity]:
|
||||||
"""Create MBUS Entities."""
|
"""Create MBUS Entities."""
|
||||||
entities = []
|
entities = []
|
||||||
@ -523,7 +523,7 @@ async def async_setup_entry(
|
|||||||
add_entities_handler: Callable[..., None] | None
|
add_entities_handler: Callable[..., None] | None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def init_async_add_entities(telegram: dict[str, DSMRObject]) -> None:
|
def init_async_add_entities(telegram: Telegram) -> None:
|
||||||
"""Add the sensor entities after the first telegram was received."""
|
"""Add the sensor entities after the first telegram was received."""
|
||||||
nonlocal add_entities_handler
|
nonlocal add_entities_handler
|
||||||
assert add_entities_handler is not None
|
assert add_entities_handler is not None
|
||||||
@ -560,7 +560,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
@Throttle(min_time_between_updates)
|
@Throttle(min_time_between_updates)
|
||||||
def update_entities_telegram(telegram: dict[str, DSMRObject] | None) -> None:
|
def update_entities_telegram(telegram: Telegram | None) -> None:
|
||||||
"""Update entities with latest telegram and trigger state update."""
|
"""Update entities with latest telegram and trigger state update."""
|
||||||
nonlocal initialized
|
nonlocal initialized
|
||||||
# Make all device entities aware of new telegram
|
# Make all device entities aware of new telegram
|
||||||
@ -709,7 +709,7 @@ class DSMREntity(SensorEntity):
|
|||||||
self,
|
self,
|
||||||
entity_description: DSMRSensorEntityDescription,
|
entity_description: DSMRSensorEntityDescription,
|
||||||
entry: ConfigEntry,
|
entry: ConfigEntry,
|
||||||
telegram: dict[str, DSMRObject],
|
telegram: Telegram,
|
||||||
device_class: SensorDeviceClass,
|
device_class: SensorDeviceClass,
|
||||||
native_unit_of_measurement: str | None,
|
native_unit_of_measurement: str | None,
|
||||||
serial_id: str = "",
|
serial_id: str = "",
|
||||||
@ -720,7 +720,7 @@ class DSMREntity(SensorEntity):
|
|||||||
self._attr_device_class = device_class
|
self._attr_device_class = device_class
|
||||||
self._attr_native_unit_of_measurement = native_unit_of_measurement
|
self._attr_native_unit_of_measurement = native_unit_of_measurement
|
||||||
self._entry = entry
|
self._entry = entry
|
||||||
self.telegram: dict[str, DSMRObject] | None = telegram
|
self.telegram: Telegram | None = telegram
|
||||||
|
|
||||||
device_serial = entry.data[CONF_SERIAL_ID]
|
device_serial = entry.data[CONF_SERIAL_ID]
|
||||||
device_name = DEVICE_NAME_ELECTRICITY
|
device_name = DEVICE_NAME_ELECTRICITY
|
||||||
@ -750,7 +750,7 @@ class DSMREntity(SensorEntity):
|
|||||||
self._attr_unique_id = f"{device_serial}_{entity_description.key}"
|
self._attr_unique_id = f"{device_serial}_{entity_description.key}"
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def update_data(self, telegram: dict[str, DSMRObject] | None) -> None:
|
def update_data(self, telegram: Telegram | None) -> None:
|
||||||
"""Update data."""
|
"""Update data."""
|
||||||
self.telegram = telegram
|
self.telegram = telegram
|
||||||
if self.hass and (
|
if self.hass and (
|
||||||
|
@ -9,7 +9,7 @@ from dsmr_parser.obis_references import (
|
|||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
||||||
BELGIUM_MBUS1_METER_READING2,
|
BELGIUM_MBUS1_METER_READING2,
|
||||||
)
|
)
|
||||||
from dsmr_parser.objects import CosemObject, MBusObject
|
from dsmr_parser.objects import CosemObject, MBusObject, Telegram
|
||||||
|
|
||||||
from homeassistant.components.dsmr.const import DOMAIN
|
from homeassistant.components.dsmr.const import DOMAIN
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
@ -65,22 +65,31 @@ async def test_migrate_gas_to_mbus(
|
|||||||
assert entity.unique_id == old_unique_id
|
assert entity.unique_id == old_unique_id
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE: CosemObject(
|
telegram.add(
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE, [{"value": "003", "unit": ""}]
|
BELGIUM_MBUS1_DEVICE_TYPE,
|
||||||
),
|
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER: CosemObject(
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 1),
|
||||||
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS1_METER_READING2: MBusObject(
|
"BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS1_METER_READING2,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_METER_READING2,
|
||||||
|
MBusObject(
|
||||||
|
(0, 1),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
||||||
{"value": Decimal(745.695), "unit": "m3"},
|
{"value": Decimal(745.695), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
}
|
"BELGIUM_MBUS1_METER_READING2",
|
||||||
|
)
|
||||||
|
|
||||||
assert await hass.config_entries.async_setup(mock_entry.entry_id)
|
assert await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -173,22 +182,31 @@ async def test_migrate_gas_to_mbus_exists(
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE: CosemObject(
|
telegram.add(
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE, [{"value": "003", "unit": ""}]
|
BELGIUM_MBUS1_DEVICE_TYPE,
|
||||||
),
|
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER: CosemObject(
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 1),
|
||||||
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS1_METER_READING2: MBusObject(
|
"BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS1_METER_READING2,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_METER_READING2,
|
||||||
|
MBusObject(
|
||||||
|
(0, 1),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
||||||
{"value": Decimal(745.695), "unit": "m3"},
|
{"value": Decimal(745.695), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
}
|
"BELGIUM_MBUS1_METER_READING2",
|
||||||
|
)
|
||||||
|
|
||||||
assert await hass.config_entries.async_setup(mock_entry.entry_id)
|
assert await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -37,7 +37,7 @@ from dsmr_parser.obis_references import (
|
|||||||
GAS_METER_READING,
|
GAS_METER_READING,
|
||||||
HOURLY_GAS_METER_READING,
|
HOURLY_GAS_METER_READING,
|
||||||
)
|
)
|
||||||
from dsmr_parser.objects import CosemObject, MBusObject
|
from dsmr_parser.objects import CosemObject, MBusObject, Telegram
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
@ -80,22 +80,31 @@ async def test_default_setup(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
CURRENT_ELECTRICITY_USAGE: CosemObject(
|
telegram.add(
|
||||||
CURRENT_ELECTRICITY_USAGE,
|
CURRENT_ELECTRICITY_USAGE,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal("0.0"), "unit": UnitOfPower.WATT}],
|
[{"value": Decimal("0.0"), "unit": UnitOfPower.WATT}],
|
||||||
),
|
),
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
"CURRENT_ELECTRICITY_USAGE",
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
GAS_METER_READING: MBusObject(
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
GAS_METER_READING,
|
CosemObject((0, 0), [{"value": "0001", "unit": ""}]),
|
||||||
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
GAS_METER_READING,
|
||||||
|
MBusObject(
|
||||||
|
(0, 0),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
||||||
{"value": Decimal(745.695), "unit": UnitOfVolume.CUBIC_METERS},
|
{"value": Decimal(745.695), "unit": UnitOfVolume.CUBIC_METERS},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
}
|
"GAS_METER_READING",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -134,22 +143,31 @@ async def test_default_setup(
|
|||||||
)
|
)
|
||||||
assert power_consumption.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "W"
|
assert power_consumption.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "W"
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
CURRENT_ELECTRICITY_USAGE: CosemObject(
|
telegram.add(
|
||||||
CURRENT_ELECTRICITY_USAGE,
|
CURRENT_ELECTRICITY_USAGE,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal("35.0"), "unit": UnitOfPower.WATT}],
|
[{"value": Decimal("35.0"), "unit": UnitOfPower.WATT}],
|
||||||
),
|
),
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
"CURRENT_ELECTRICITY_USAGE",
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
GAS_METER_READING: MBusObject(
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
GAS_METER_READING,
|
CosemObject((0, 0), [{"value": "0001", "unit": ""}]),
|
||||||
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
GAS_METER_READING,
|
||||||
|
MBusObject(
|
||||||
|
(0, 0),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642214)},
|
{"value": datetime.datetime.fromtimestamp(1551642214)},
|
||||||
{"value": Decimal(745.701), "unit": UnitOfVolume.CUBIC_METERS},
|
{"value": Decimal(745.701), "unit": UnitOfVolume.CUBIC_METERS},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
}
|
"GAS_METER_READING",
|
||||||
|
)
|
||||||
|
|
||||||
# simulate a telegram pushed from the smartmeter and parsed by dsmr_parser
|
# simulate a telegram pushed from the smartmeter and parsed by dsmr_parser
|
||||||
telegram_callback(telegram)
|
telegram_callback(telegram)
|
||||||
@ -209,15 +227,20 @@ async def test_setup_only_energy(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
CURRENT_ELECTRICITY_USAGE: CosemObject(
|
telegram.add(
|
||||||
CURRENT_ELECTRICITY_USAGE,
|
CURRENT_ELECTRICITY_USAGE,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal("35.0"), "unit": UnitOfPower.WATT}],
|
[{"value": Decimal("35.0"), "unit": UnitOfPower.WATT}],
|
||||||
),
|
),
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
"CURRENT_ELECTRICITY_USAGE",
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
}
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
|
CosemObject((0, 0), [{"value": "0001", "unit": ""}]),
|
||||||
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -260,18 +283,23 @@ async def test_v4_meter(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
HOURLY_GAS_METER_READING: MBusObject(
|
telegram.add(
|
||||||
HOURLY_GAS_METER_READING,
|
HOURLY_GAS_METER_READING,
|
||||||
|
MBusObject(
|
||||||
|
(0, 0),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
||||||
{"value": Decimal(745.695), "unit": "m3"},
|
{"value": Decimal(745.695), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
"HOURLY_GAS_METER_READING",
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
}
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
|
CosemObject((0, 0), [{"value": "0001", "unit": ""}]),
|
||||||
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -343,18 +371,23 @@ async def test_v5_meter(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
HOURLY_GAS_METER_READING: MBusObject(
|
telegram.add(
|
||||||
HOURLY_GAS_METER_READING,
|
HOURLY_GAS_METER_READING,
|
||||||
|
MBusObject(
|
||||||
|
(0, 0),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
||||||
{"value": value, "unit": "m3"},
|
{"value": value, "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
"HOURLY_GAS_METER_READING",
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
}
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
|
CosemObject((0, 0), [{"value": "0001", "unit": ""}]),
|
||||||
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -411,23 +444,34 @@ async def test_luxembourg_meter(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
HOURLY_GAS_METER_READING: MBusObject(
|
telegram.add(
|
||||||
HOURLY_GAS_METER_READING,
|
HOURLY_GAS_METER_READING,
|
||||||
|
MBusObject(
|
||||||
|
(0, 0),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
||||||
{"value": Decimal(745.695), "unit": "m3"},
|
{"value": Decimal(745.695), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ELECTRICITY_IMPORTED_TOTAL: CosemObject(
|
"HOURLY_GAS_METER_READING",
|
||||||
ELECTRICITY_IMPORTED_TOTAL,
|
)
|
||||||
|
telegram.add(
|
||||||
|
ELECTRICITY_IMPORTED_TOTAL,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal(123.456), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
[{"value": Decimal(123.456), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
||||||
),
|
),
|
||||||
ELECTRICITY_EXPORTED_TOTAL: CosemObject(
|
"ELECTRICITY_IMPORTED_TOTAL",
|
||||||
ELECTRICITY_EXPORTED_TOTAL,
|
)
|
||||||
|
telegram.add(
|
||||||
|
ELECTRICITY_EXPORTED_TOTAL,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal(654.321), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
[{"value": Decimal(654.321), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
||||||
),
|
),
|
||||||
}
|
"ELECTRICITY_EXPORTED_TOTAL",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -495,78 +539,127 @@ async def test_belgian_meter(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
BELGIUM_CURRENT_AVERAGE_DEMAND: CosemObject(
|
telegram.add(
|
||||||
BELGIUM_CURRENT_AVERAGE_DEMAND,
|
BELGIUM_CURRENT_AVERAGE_DEMAND,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal(1.75), "unit": "kW"}],
|
[{"value": Decimal(1.75), "unit": "kW"}],
|
||||||
),
|
),
|
||||||
BELGIUM_MAXIMUM_DEMAND_MONTH: MBusObject(
|
"BELGIUM_CURRENT_AVERAGE_DEMAND",
|
||||||
BELGIUM_MAXIMUM_DEMAND_MONTH,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MAXIMUM_DEMAND_MONTH,
|
||||||
|
MBusObject(
|
||||||
|
(0, 0),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642218)},
|
{"value": datetime.datetime.fromtimestamp(1551642218)},
|
||||||
{"value": Decimal(4.11), "unit": "kW"},
|
{"value": Decimal(4.11), "unit": "kW"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MAXIMUM_DEMAND_MONTH",
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE, [{"value": "003", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS1_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 1), [{"value": "003", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 1),
|
||||||
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS1_METER_READING2: MBusObject(
|
"BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS1_METER_READING2,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_METER_READING2,
|
||||||
|
MBusObject(
|
||||||
|
(0, 1),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
||||||
{"value": Decimal(745.695), "unit": "m3"},
|
{"value": Decimal(745.695), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MBUS1_METER_READING2",
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE, [{"value": "007", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS2_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS2_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 2),
|
||||||
[{"value": "37464C4F32313139303333373332", "unit": ""}],
|
[{"value": "37464C4F32313139303333373332", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS2_METER_READING1: MBusObject(
|
"BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS2_METER_READING1,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS2_METER_READING1,
|
||||||
|
MBusObject(
|
||||||
|
(0, 2),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642214)},
|
{"value": datetime.datetime.fromtimestamp(1551642214)},
|
||||||
{"value": Decimal(678.695), "unit": "m3"},
|
{"value": Decimal(678.695), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MBUS2_METER_READING1",
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE, [{"value": "003", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS3_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS3_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 3),
|
||||||
[{"value": "37464C4F32313139303333373333", "unit": ""}],
|
[{"value": "37464C4F32313139303333373333", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS3_METER_READING2: MBusObject(
|
"BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS3_METER_READING2,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS3_METER_READING2,
|
||||||
|
MBusObject(
|
||||||
|
(0, 3),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642215)},
|
{"value": datetime.datetime.fromtimestamp(1551642215)},
|
||||||
{"value": Decimal(12.12), "unit": "m3"},
|
{"value": Decimal(12.12), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MBUS3_METER_READING2",
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE, [{"value": "007", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS4_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS4_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 4),
|
||||||
[{"value": "37464C4F32313139303333373334", "unit": ""}],
|
[{"value": "37464C4F32313139303333373334", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS4_METER_READING1: MBusObject(
|
"BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS4_METER_READING1,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS4_METER_READING1,
|
||||||
|
MBusObject(
|
||||||
|
(0, 4),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642216)},
|
{"value": datetime.datetime.fromtimestamp(1551642216)},
|
||||||
{"value": Decimal(13.13), "unit": "m3"},
|
{"value": Decimal(13.13), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
"BELGIUM_MBUS4_METER_READING1",
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
}
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
|
CosemObject((0, 0), [{"value": "0001", "unit": ""}]),
|
||||||
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -680,64 +773,103 @@ async def test_belgian_meter_alt(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE: CosemObject(
|
telegram.add(
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE, [{"value": "007", "unit": ""}]
|
BELGIUM_MBUS1_DEVICE_TYPE,
|
||||||
),
|
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER: CosemObject(
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 1),
|
||||||
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS1_METER_READING1: MBusObject(
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
BELGIUM_MBUS1_METER_READING1,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_METER_READING1,
|
||||||
|
MBusObject(
|
||||||
|
(0, 1),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642215)},
|
{"value": datetime.datetime.fromtimestamp(1551642215)},
|
||||||
{"value": Decimal(123.456), "unit": "m3"},
|
{"value": Decimal(123.456), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MBUS1_METER_READING1",
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE, [{"value": "003", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS2_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS2_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 2),
|
||||||
[{"value": "37464C4F32313139303333373332", "unit": ""}],
|
[{"value": "37464C4F32313139303333373332", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS2_METER_READING2: MBusObject(
|
"BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS2_METER_READING2,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS2_METER_READING2,
|
||||||
|
MBusObject(
|
||||||
|
(0, 2),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642216)},
|
{"value": datetime.datetime.fromtimestamp(1551642216)},
|
||||||
{"value": Decimal(678.901), "unit": "m3"},
|
{"value": Decimal(678.901), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE: CosemObject(
|
BELGIUM_MBUS2_METER_READING2,
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE, [{"value": "007", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS3_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS3_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 3),
|
||||||
[{"value": "37464C4F32313139303333373333", "unit": ""}],
|
[{"value": "37464C4F32313139303333373333", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS3_METER_READING1: MBusObject(
|
"BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS3_METER_READING1,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS3_METER_READING1,
|
||||||
|
MBusObject(
|
||||||
|
(0, 3),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642217)},
|
{"value": datetime.datetime.fromtimestamp(1551642217)},
|
||||||
{"value": Decimal(12.12), "unit": "m3"},
|
{"value": Decimal(12.12), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MBUS3_METER_READING1",
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE, [{"value": "003", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS4_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS4_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 4),
|
||||||
[{"value": "37464C4F32313139303333373334", "unit": ""}],
|
[{"value": "37464C4F32313139303333373334", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS4_METER_READING2: MBusObject(
|
"BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS4_METER_READING2,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS4_METER_READING2,
|
||||||
|
MBusObject(
|
||||||
|
(0, 4),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642218)},
|
{"value": datetime.datetime.fromtimestamp(1551642218)},
|
||||||
{"value": Decimal(13.13), "unit": "m3"},
|
{"value": Decimal(13.13), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
}
|
"BELGIUM_MBUS4_METER_READING2",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -829,49 +961,78 @@ async def test_belgian_meter_mbus(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
telegram.add(
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0003", "unit": ""}]
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
),
|
CosemObject((0, 0), [{"value": "0003", "unit": ""}]),
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE: CosemObject(
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE, [{"value": "006", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS1_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "006", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 1),
|
||||||
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE, [{"value": "003", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS2_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS2_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 2),
|
||||||
[{"value": "37464C4F32313139303333373332", "unit": ""}],
|
[{"value": "37464C4F32313139303333373332", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE, [{"value": "007", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER: CosemObject(
|
BELGIUM_MBUS3_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
|
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS3_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
|
||||||
|
CosemObject(
|
||||||
|
(0, 3),
|
||||||
[{"value": "37464C4F32313139303333373333", "unit": ""}],
|
[{"value": "37464C4F32313139303333373333", "unit": ""}],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS3_METER_READING2: MBusObject(
|
"BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER",
|
||||||
BELGIUM_MBUS3_METER_READING2,
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS3_METER_READING2,
|
||||||
|
MBusObject(
|
||||||
|
(0, 3),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642217)},
|
{"value": datetime.datetime.fromtimestamp(1551642217)},
|
||||||
{"value": Decimal(12.12), "unit": "m3"},
|
{"value": Decimal(12.12), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE: CosemObject(
|
"BELGIUM_MBUS3_METER_READING2",
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE, [{"value": "007", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
BELGIUM_MBUS4_METER_READING1: MBusObject(
|
BELGIUM_MBUS4_DEVICE_TYPE,
|
||||||
BELGIUM_MBUS4_METER_READING1,
|
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
||||||
|
"BELGIUM_MBUS4_DEVICE_TYPE",
|
||||||
|
)
|
||||||
|
telegram.add(
|
||||||
|
BELGIUM_MBUS4_METER_READING1,
|
||||||
|
MBusObject(
|
||||||
|
(0, 4),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642218)},
|
{"value": datetime.datetime.fromtimestamp(1551642218)},
|
||||||
{"value": Decimal(13.13), "unit": "m3"},
|
{"value": Decimal(13.13), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
}
|
"BELGIUM_MBUS4_METER_READING1",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -938,11 +1099,12 @@ async def test_belgian_meter_low(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
telegram.add(
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0002", "unit": ""}]
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
)
|
CosemObject((0, 0), [{"value": "0002", "unit": ""}]),
|
||||||
}
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -986,16 +1148,23 @@ async def test_swedish_meter(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
ELECTRICITY_IMPORTED_TOTAL: CosemObject(
|
telegram.add(
|
||||||
ELECTRICITY_IMPORTED_TOTAL,
|
ELECTRICITY_IMPORTED_TOTAL,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal(123.456), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
[{"value": Decimal(123.456), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
||||||
),
|
),
|
||||||
ELECTRICITY_EXPORTED_TOTAL: CosemObject(
|
"ELECTRICITY_IMPORTED_TOTAL",
|
||||||
ELECTRICITY_EXPORTED_TOTAL,
|
)
|
||||||
|
telegram.add(
|
||||||
|
ELECTRICITY_EXPORTED_TOTAL,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal(654.321), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
[{"value": Decimal(654.321), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
||||||
),
|
),
|
||||||
}
|
"ELECTRICITY_EXPORTED_TOTAL",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
@ -1054,16 +1223,23 @@ async def test_easymeter(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
ELECTRICITY_IMPORTED_TOTAL: CosemObject(
|
telegram.add(
|
||||||
ELECTRICITY_IMPORTED_TOTAL,
|
ELECTRICITY_IMPORTED_TOTAL,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal(54184.6316), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
[{"value": Decimal(54184.6316), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
||||||
),
|
),
|
||||||
ELECTRICITY_EXPORTED_TOTAL: CosemObject(
|
"ELECTRICITY_IMPORTED_TOTAL",
|
||||||
ELECTRICITY_EXPORTED_TOTAL,
|
)
|
||||||
|
telegram.add(
|
||||||
|
ELECTRICITY_EXPORTED_TOTAL,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal(19981.1069), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
[{"value": Decimal(19981.1069), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
|
||||||
),
|
),
|
||||||
}
|
"ELECTRICITY_EXPORTED_TOTAL",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr",
|
domain="dsmr",
|
||||||
@ -1222,15 +1398,20 @@ async def test_reconnect(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
CURRENT_ELECTRICITY_USAGE: CosemObject(
|
telegram.add(
|
||||||
CURRENT_ELECTRICITY_USAGE,
|
CURRENT_ELECTRICITY_USAGE,
|
||||||
|
CosemObject(
|
||||||
|
(0, 0),
|
||||||
[{"value": Decimal("35.0"), "unit": UnitOfPower.WATT}],
|
[{"value": Decimal("35.0"), "unit": UnitOfPower.WATT}],
|
||||||
),
|
),
|
||||||
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
|
"CURRENT_ELECTRICITY_USAGE",
|
||||||
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
|
)
|
||||||
),
|
telegram.add(
|
||||||
}
|
ELECTRICITY_ACTIVE_TARIFF,
|
||||||
|
CosemObject((0, 0), [{"value": "0001", "unit": ""}]),
|
||||||
|
"ELECTRICITY_ACTIVE_TARIFF",
|
||||||
|
)
|
||||||
|
|
||||||
# mock waiting coroutine while connection lasts
|
# mock waiting coroutine while connection lasts
|
||||||
closed = asyncio.Event()
|
closed = asyncio.Event()
|
||||||
@ -1300,15 +1481,18 @@ async def test_gas_meter_providing_energy_reading(
|
|||||||
"time_between_update": 0,
|
"time_between_update": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram = {
|
telegram = Telegram()
|
||||||
GAS_METER_READING: MBusObject(
|
telegram.add(
|
||||||
GAS_METER_READING,
|
GAS_METER_READING,
|
||||||
|
MBusObject(
|
||||||
|
(0, 0),
|
||||||
[
|
[
|
||||||
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
{"value": datetime.datetime.fromtimestamp(1551642213)},
|
||||||
{"value": Decimal(123.456), "unit": UnitOfEnergy.GIGA_JOULE},
|
{"value": Decimal(123.456), "unit": UnitOfEnergy.GIGA_JOULE},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
}
|
"GAS_METER_READING",
|
||||||
|
)
|
||||||
|
|
||||||
mock_entry = MockConfigEntry(
|
mock_entry = MockConfigEntry(
|
||||||
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
domain="dsmr", unique_id="/dev/ttyUSB0", data=entry_data, options=entry_options
|
||||||
|
Loading…
x
Reference in New Issue
Block a user