Bump dsmr_parser to 1.3.0 (#102225)

bump dsmr_parser==1.3.0
This commit is contained in:
dupondje 2023-10-18 18:13:09 +02:00 committed by GitHub
parent eee294d384
commit 1b73219137
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 77 additions and 36 deletions

View file

@ -34,3 +34,6 @@ DSMR_VERSIONS = {"2.2", "4", "5", "5B", "5L", "5S", "Q3D"}
DSMR_PROTOCOL = "dsmr_protocol" DSMR_PROTOCOL = "dsmr_protocol"
RFXTRX_DSMR_PROTOCOL = "rfxtrx_dsmr_protocol" RFXTRX_DSMR_PROTOCOL = "rfxtrx_dsmr_protocol"
# Temp obis until sensors replaced by mbus variants
BELGIUM_5MIN_GAS_METER_READING = r"\d-\d:24\.2\.3.+?\r\n"

View file

@ -7,5 +7,5 @@
"integration_type": "hub", "integration_type": "hub",
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["dsmr_parser"], "loggers": ["dsmr_parser"],
"requirements": ["dsmr-parser==0.33"] "requirements": ["dsmr-parser==1.3.0"]
} }

View file

@ -39,6 +39,7 @@ from homeassistant.helpers.typing import StateType
from homeassistant.util import Throttle from homeassistant.util import Throttle
from .const import ( from .const import (
BELGIUM_5MIN_GAS_METER_READING,
CONF_DSMR_VERSION, CONF_DSMR_VERSION,
CONF_PRECISION, CONF_PRECISION,
CONF_PROTOCOL, CONF_PROTOCOL,
@ -361,7 +362,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
DSMRSensorEntityDescription( DSMRSensorEntityDescription(
key="belgium_5min_gas_meter_reading", key="belgium_5min_gas_meter_reading",
translation_key="gas_meter_reading", translation_key="gas_meter_reading",
obis_reference=obis_references.BELGIUM_5MIN_GAS_METER_READING, obis_reference=BELGIUM_5MIN_GAS_METER_READING,
dsmr_versions={"5B"}, dsmr_versions={"5B"},
is_gas=True, is_gas=True,
force_update=True, force_update=True,

View file

@ -701,7 +701,7 @@ dovado==0.4.1
dremel3dpy==2.1.1 dremel3dpy==2.1.1
# homeassistant.components.dsmr # homeassistant.components.dsmr
dsmr-parser==0.33 dsmr-parser==1.3.0
# homeassistant.components.dwd_weather_warnings # homeassistant.components.dwd_weather_warnings
dwdwfsapi==1.0.6 dwdwfsapi==1.0.6

View file

@ -572,7 +572,7 @@ discovery30303==0.2.1
dremel3dpy==2.1.1 dremel3dpy==2.1.1
# homeassistant.components.dsmr # homeassistant.components.dsmr
dsmr-parser==0.33 dsmr-parser==1.3.0
# homeassistant.components.dwd_weather_warnings # homeassistant.components.dwd_weather_warnings
dwdwfsapi==1.0.6 dwdwfsapi==1.0.6

View file

@ -68,9 +68,15 @@ async def dsmr_connection_send_validate_fixture(hass):
protocol = MagicMock(spec=DSMRProtocol) protocol = MagicMock(spec=DSMRProtocol)
protocol.telegram = { protocol.telegram = {
EQUIPMENT_IDENTIFIER: CosemObject([{"value": "12345678", "unit": ""}]), EQUIPMENT_IDENTIFIER: CosemObject(
EQUIPMENT_IDENTIFIER_GAS: CosemObject([{"value": "123456789", "unit": ""}]), EQUIPMENT_IDENTIFIER, [{"value": "12345678", "unit": ""}]
P1_MESSAGE_TIMESTAMP: CosemObject([{"value": "12345678", "unit": ""}]), ),
EQUIPMENT_IDENTIFIER_GAS: CosemObject(
EQUIPMENT_IDENTIFIER_GAS, [{"value": "123456789", "unit": ""}]
),
P1_MESSAGE_TIMESTAMP: CosemObject(
P1_MESSAGE_TIMESTAMP, [{"value": "12345678", "unit": ""}]
),
} }
async def connection_factory(*args, **kwargs): async def connection_factory(*args, **kwargs):
@ -78,20 +84,22 @@ async def dsmr_connection_send_validate_fixture(hass):
if args[1] == "5L": if args[1] == "5L":
protocol.telegram = { protocol.telegram = {
LUXEMBOURG_EQUIPMENT_IDENTIFIER: CosemObject( LUXEMBOURG_EQUIPMENT_IDENTIFIER: CosemObject(
[{"value": "12345678", "unit": ""}] LUXEMBOURG_EQUIPMENT_IDENTIFIER, [{"value": "12345678", "unit": ""}]
), ),
EQUIPMENT_IDENTIFIER_GAS: CosemObject( EQUIPMENT_IDENTIFIER_GAS: CosemObject(
[{"value": "123456789", "unit": ""}] EQUIPMENT_IDENTIFIER_GAS, [{"value": "123456789", "unit": ""}]
), ),
} }
if args[1] == "5S": if args[1] == "5S":
protocol.telegram = { protocol.telegram = {
P1_MESSAGE_TIMESTAMP: CosemObject([{"value": "12345678", "unit": ""}]), P1_MESSAGE_TIMESTAMP: CosemObject(
P1_MESSAGE_TIMESTAMP, [{"value": "12345678", "unit": ""}]
),
} }
if args[1] == "Q3D": if args[1] == "Q3D":
protocol.telegram = { protocol.telegram = {
Q3D_EQUIPMENT_IDENTIFIER: CosemObject( Q3D_EQUIPMENT_IDENTIFIER: CosemObject(
[{"value": "12345678", "unit": ""}] Q3D_EQUIPMENT_IDENTIFIER, [{"value": "12345678", "unit": ""}]
), ),
} }
@ -129,9 +137,15 @@ async def rfxtrx_dsmr_connection_send_validate_fixture(hass):
protocol = MagicMock(spec=RFXtrxDSMRProtocol) protocol = MagicMock(spec=RFXtrxDSMRProtocol)
protocol.telegram = { protocol.telegram = {
EQUIPMENT_IDENTIFIER: CosemObject([{"value": "12345678", "unit": ""}]), EQUIPMENT_IDENTIFIER: CosemObject(
EQUIPMENT_IDENTIFIER_GAS: CosemObject([{"value": "123456789", "unit": ""}]), EQUIPMENT_IDENTIFIER, [{"value": "12345678", "unit": ""}]
P1_MESSAGE_TIMESTAMP: CosemObject([{"value": "12345678", "unit": ""}]), ),
EQUIPMENT_IDENTIFIER_GAS: CosemObject(
EQUIPMENT_IDENTIFIER_GAS, [{"value": "123456789", "unit": ""}]
),
P1_MESSAGE_TIMESTAMP: CosemObject(
P1_MESSAGE_TIMESTAMP, [{"value": "12345678", "unit": ""}]
),
} }
async def connection_factory(*args, **kwargs): async def connection_factory(*args, **kwargs):

View file

@ -11,6 +11,7 @@ from itertools import chain, repeat
from unittest.mock import DEFAULT, MagicMock from unittest.mock import DEFAULT, MagicMock
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.dsmr.const import BELGIUM_5MIN_GAS_METER_READING
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
ATTR_OPTIONS, ATTR_OPTIONS,
ATTR_STATE_CLASS, ATTR_STATE_CLASS,
@ -59,14 +60,18 @@ async def test_default_setup(hass: HomeAssistant, dsmr_connection_fixture) -> No
telegram = { telegram = {
CURRENT_ELECTRICITY_USAGE: CosemObject( CURRENT_ELECTRICITY_USAGE: CosemObject(
[{"value": Decimal("0.0"), "unit": UnitOfPower.WATT}] CURRENT_ELECTRICITY_USAGE,
[{"value": Decimal("0.0"), "unit": UnitOfPower.WATT}],
),
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
), ),
ELECTRICITY_ACTIVE_TARIFF: CosemObject([{"value": "0001", "unit": ""}]),
GAS_METER_READING: MBusObject( GAS_METER_READING: MBusObject(
GAS_METER_READING,
[ [
{"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},
] ],
), ),
} }
@ -199,12 +204,15 @@ async def test_v4_meter(hass: HomeAssistant, dsmr_connection_fixture) -> None:
telegram = { telegram = {
HOURLY_GAS_METER_READING: MBusObject( HOURLY_GAS_METER_READING: MBusObject(
HOURLY_GAS_METER_READING,
[ [
{"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(
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
), ),
ELECTRICITY_ACTIVE_TARIFF: CosemObject([{"value": "0001", "unit": ""}]),
} }
mock_entry = MockConfigEntry( mock_entry = MockConfigEntry(
@ -275,12 +283,15 @@ async def test_v5_meter(hass: HomeAssistant, dsmr_connection_fixture) -> None:
telegram = { telegram = {
HOURLY_GAS_METER_READING: MBusObject( HOURLY_GAS_METER_READING: MBusObject(
HOURLY_GAS_METER_READING,
[ [
{"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(
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
), ),
ELECTRICITY_ACTIVE_TARIFF: CosemObject([{"value": "0001", "unit": ""}]),
} }
mock_entry = MockConfigEntry( mock_entry = MockConfigEntry(
@ -348,16 +359,19 @@ async def test_luxembourg_meter(hass: HomeAssistant, dsmr_connection_fixture) ->
telegram = { telegram = {
HOURLY_GAS_METER_READING: MBusObject( HOURLY_GAS_METER_READING: MBusObject(
HOURLY_GAS_METER_READING,
[ [
{"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( ELECTRICITY_IMPORTED_TOTAL: CosemObject(
[{"value": Decimal(123.456), "unit": UnitOfEnergy.KILO_WATT_HOUR}] ELECTRICITY_IMPORTED_TOTAL,
[{"value": Decimal(123.456), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
), ),
ELECTRICITY_EXPORTED_TOTAL: CosemObject( ELECTRICITY_EXPORTED_TOTAL: CosemObject(
[{"value": Decimal(654.321), "unit": UnitOfEnergy.KILO_WATT_HOUR}] ELECTRICITY_EXPORTED_TOTAL,
[{"value": Decimal(654.321), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
), ),
} }
@ -416,10 +430,7 @@ 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 ( from dsmr_parser.obis_references import ELECTRICITY_ACTIVE_TARIFF
BELGIUM_5MIN_GAS_METER_READING,
ELECTRICITY_ACTIVE_TARIFF,
)
from dsmr_parser.objects import CosemObject, MBusObject from dsmr_parser.objects import CosemObject, MBusObject
entry_data = { entry_data = {
@ -436,12 +447,15 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No
telegram = { telegram = {
BELGIUM_5MIN_GAS_METER_READING: MBusObject( BELGIUM_5MIN_GAS_METER_READING: MBusObject(
BELGIUM_5MIN_GAS_METER_READING,
[ [
{"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(
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}]
), ),
ELECTRICITY_ACTIVE_TARIFF: CosemObject([{"value": "0001", "unit": ""}]),
} }
mock_entry = MockConfigEntry( mock_entry = MockConfigEntry(
@ -503,7 +517,11 @@ async def test_belgian_meter_low(hass: HomeAssistant, dsmr_connection_fixture) -
"time_between_update": 0, "time_between_update": 0,
} }
telegram = {ELECTRICITY_ACTIVE_TARIFF: CosemObject([{"value": "0002", "unit": ""}])} telegram = {
ELECTRICITY_ACTIVE_TARIFF: CosemObject(
ELECTRICITY_ACTIVE_TARIFF, [{"value": "0002", "unit": ""}]
)
}
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
@ -556,10 +574,12 @@ async def test_swedish_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No
telegram = { telegram = {
ELECTRICITY_IMPORTED_TOTAL: CosemObject( ELECTRICITY_IMPORTED_TOTAL: CosemObject(
[{"value": Decimal(123.456), "unit": UnitOfEnergy.KILO_WATT_HOUR}] ELECTRICITY_IMPORTED_TOTAL,
[{"value": Decimal(123.456), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
), ),
ELECTRICITY_EXPORTED_TOTAL: CosemObject( ELECTRICITY_EXPORTED_TOTAL: CosemObject(
[{"value": Decimal(654.321), "unit": UnitOfEnergy.KILO_WATT_HOUR}] ELECTRICITY_EXPORTED_TOTAL,
[{"value": Decimal(654.321), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
), ),
} }
@ -629,10 +649,12 @@ async def test_easymeter(hass: HomeAssistant, dsmr_connection_fixture) -> None:
telegram = { telegram = {
ELECTRICITY_IMPORTED_TOTAL: CosemObject( ELECTRICITY_IMPORTED_TOTAL: CosemObject(
[{"value": Decimal(54184.6316), "unit": UnitOfEnergy.KILO_WATT_HOUR}] ELECTRICITY_IMPORTED_TOTAL,
[{"value": Decimal(54184.6316), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
), ),
ELECTRICITY_EXPORTED_TOTAL: CosemObject( ELECTRICITY_EXPORTED_TOTAL: CosemObject(
[{"value": Decimal(19981.1069), "unit": UnitOfEnergy.KILO_WATT_HOUR}] ELECTRICITY_EXPORTED_TOTAL,
[{"value": Decimal(19981.1069), "unit": UnitOfEnergy.KILO_WATT_HOUR}],
), ),
} }
@ -856,10 +878,11 @@ async def test_gas_meter_providing_energy_reading(
telegram = { telegram = {
GAS_METER_READING: MBusObject( GAS_METER_READING: MBusObject(
GAS_METER_READING,
[ [
{"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},
] ],
), ),
} }