Continue transition from legacy dict to attr in dsmr (#121906)
This commit is contained in:
parent
fed17a4905
commit
a1cdd91d23
3 changed files with 77 additions and 92 deletions
|
@ -10,7 +10,6 @@ from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from dsmr_parser import obis_references
|
|
||||||
from dsmr_parser.clients.protocol import create_dsmr_reader, create_tcp_dsmr_reader
|
from dsmr_parser.clients.protocol import create_dsmr_reader, create_tcp_dsmr_reader
|
||||||
from dsmr_parser.clients.rfxtrx_protocol import (
|
from dsmr_parser.clients.rfxtrx_protocol import (
|
||||||
create_rfxtrx_dsmr_reader,
|
create_rfxtrx_dsmr_reader,
|
||||||
|
@ -81,7 +80,7 @@ class DSMRSensorEntityDescription(SensorEntityDescription):
|
||||||
SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="timestamp",
|
key="timestamp",
|
||||||
obis_reference=obis_references.P1_MESSAGE_TIMESTAMP,
|
obis_reference="P1_MESSAGE_TIMESTAMP",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -89,21 +88,21 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="current_electricity_usage",
|
key="current_electricity_usage",
|
||||||
translation_key="current_electricity_usage",
|
translation_key="current_electricity_usage",
|
||||||
obis_reference=obis_references.CURRENT_ELECTRICITY_USAGE,
|
obis_reference="CURRENT_ELECTRICITY_USAGE",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="current_electricity_delivery",
|
key="current_electricity_delivery",
|
||||||
translation_key="current_electricity_delivery",
|
translation_key="current_electricity_delivery",
|
||||||
obis_reference=obis_references.CURRENT_ELECTRICITY_DELIVERY,
|
obis_reference="CURRENT_ELECTRICITY_DELIVERY",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="electricity_active_tariff",
|
key="electricity_active_tariff",
|
||||||
translation_key="electricity_active_tariff",
|
translation_key="electricity_active_tariff",
|
||||||
obis_reference=obis_references.ELECTRICITY_ACTIVE_TARIFF,
|
obis_reference="ELECTRICITY_ACTIVE_TARIFF",
|
||||||
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
options=["low", "normal"],
|
options=["low", "normal"],
|
||||||
|
@ -111,7 +110,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="electricity_used_tariff_1",
|
key="electricity_used_tariff_1",
|
||||||
translation_key="electricity_used_tariff_1",
|
translation_key="electricity_used_tariff_1",
|
||||||
obis_reference=obis_references.ELECTRICITY_USED_TARIFF_1,
|
obis_reference="ELECTRICITY_USED_TARIFF_1",
|
||||||
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
@ -119,7 +118,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="electricity_used_tariff_2",
|
key="electricity_used_tariff_2",
|
||||||
translation_key="electricity_used_tariff_2",
|
translation_key="electricity_used_tariff_2",
|
||||||
obis_reference=obis_references.ELECTRICITY_USED_TARIFF_2,
|
obis_reference="ELECTRICITY_USED_TARIFF_2",
|
||||||
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
@ -127,7 +126,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="electricity_delivered_tariff_1",
|
key="electricity_delivered_tariff_1",
|
||||||
translation_key="electricity_delivered_tariff_1",
|
translation_key="electricity_delivered_tariff_1",
|
||||||
obis_reference=obis_references.ELECTRICITY_DELIVERED_TARIFF_1,
|
obis_reference="ELECTRICITY_DELIVERED_TARIFF_1",
|
||||||
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
@ -135,7 +134,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="electricity_delivered_tariff_2",
|
key="electricity_delivered_tariff_2",
|
||||||
translation_key="electricity_delivered_tariff_2",
|
translation_key="electricity_delivered_tariff_2",
|
||||||
obis_reference=obis_references.ELECTRICITY_DELIVERED_TARIFF_2,
|
obis_reference="ELECTRICITY_DELIVERED_TARIFF_2",
|
||||||
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5B", "5L"},
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
@ -143,7 +142,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_active_power_l1_positive",
|
key="instantaneous_active_power_l1_positive",
|
||||||
translation_key="instantaneous_active_power_l1_positive",
|
translation_key="instantaneous_active_power_l1_positive",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_ACTIVE_POWER_L1_POSITIVE,
|
obis_reference="INSTANTANEOUS_ACTIVE_POWER_L1_POSITIVE",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -151,7 +150,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_active_power_l2_positive",
|
key="instantaneous_active_power_l2_positive",
|
||||||
translation_key="instantaneous_active_power_l2_positive",
|
translation_key="instantaneous_active_power_l2_positive",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_ACTIVE_POWER_L2_POSITIVE,
|
obis_reference="INSTANTANEOUS_ACTIVE_POWER_L2_POSITIVE",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -159,7 +158,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_active_power_l3_positive",
|
key="instantaneous_active_power_l3_positive",
|
||||||
translation_key="instantaneous_active_power_l3_positive",
|
translation_key="instantaneous_active_power_l3_positive",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_ACTIVE_POWER_L3_POSITIVE,
|
obis_reference="INSTANTANEOUS_ACTIVE_POWER_L3_POSITIVE",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -167,7 +166,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_active_power_l1_negative",
|
key="instantaneous_active_power_l1_negative",
|
||||||
translation_key="instantaneous_active_power_l1_negative",
|
translation_key="instantaneous_active_power_l1_negative",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_ACTIVE_POWER_L1_NEGATIVE,
|
obis_reference="INSTANTANEOUS_ACTIVE_POWER_L1_NEGATIVE",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -175,7 +174,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_active_power_l2_negative",
|
key="instantaneous_active_power_l2_negative",
|
||||||
translation_key="instantaneous_active_power_l2_negative",
|
translation_key="instantaneous_active_power_l2_negative",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_ACTIVE_POWER_L2_NEGATIVE,
|
obis_reference="INSTANTANEOUS_ACTIVE_POWER_L2_NEGATIVE",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -183,7 +182,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_active_power_l3_negative",
|
key="instantaneous_active_power_l3_negative",
|
||||||
translation_key="instantaneous_active_power_l3_negative",
|
translation_key="instantaneous_active_power_l3_negative",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_ACTIVE_POWER_L3_NEGATIVE,
|
obis_reference="INSTANTANEOUS_ACTIVE_POWER_L3_NEGATIVE",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -191,7 +190,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="short_power_failure_count",
|
key="short_power_failure_count",
|
||||||
translation_key="short_power_failure_count",
|
translation_key="short_power_failure_count",
|
||||||
obis_reference=obis_references.SHORT_POWER_FAILURE_COUNT,
|
obis_reference="SHORT_POWER_FAILURE_COUNT",
|
||||||
dsmr_versions={"2.2", "4", "5", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5L"},
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -199,7 +198,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="long_power_failure_count",
|
key="long_power_failure_count",
|
||||||
translation_key="long_power_failure_count",
|
translation_key="long_power_failure_count",
|
||||||
obis_reference=obis_references.LONG_POWER_FAILURE_COUNT,
|
obis_reference="LONG_POWER_FAILURE_COUNT",
|
||||||
dsmr_versions={"2.2", "4", "5", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5L"},
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -207,7 +206,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="voltage_sag_l1_count",
|
key="voltage_sag_l1_count",
|
||||||
translation_key="voltage_sag_l1_count",
|
translation_key="voltage_sag_l1_count",
|
||||||
obis_reference=obis_references.VOLTAGE_SAG_L1_COUNT,
|
obis_reference="VOLTAGE_SAG_L1_COUNT",
|
||||||
dsmr_versions={"2.2", "4", "5", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5L"},
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -215,7 +214,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="voltage_sag_l2_count",
|
key="voltage_sag_l2_count",
|
||||||
translation_key="voltage_sag_l2_count",
|
translation_key="voltage_sag_l2_count",
|
||||||
obis_reference=obis_references.VOLTAGE_SAG_L2_COUNT,
|
obis_reference="VOLTAGE_SAG_L2_COUNT",
|
||||||
dsmr_versions={"2.2", "4", "5", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5L"},
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -223,7 +222,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="voltage_sag_l3_count",
|
key="voltage_sag_l3_count",
|
||||||
translation_key="voltage_sag_l3_count",
|
translation_key="voltage_sag_l3_count",
|
||||||
obis_reference=obis_references.VOLTAGE_SAG_L3_COUNT,
|
obis_reference="VOLTAGE_SAG_L3_COUNT",
|
||||||
dsmr_versions={"2.2", "4", "5", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5L"},
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -231,7 +230,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="voltage_swell_l1_count",
|
key="voltage_swell_l1_count",
|
||||||
translation_key="voltage_swell_l1_count",
|
translation_key="voltage_swell_l1_count",
|
||||||
obis_reference=obis_references.VOLTAGE_SWELL_L1_COUNT,
|
obis_reference="VOLTAGE_SWELL_L1_COUNT",
|
||||||
dsmr_versions={"2.2", "4", "5", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5L"},
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -239,7 +238,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="voltage_swell_l2_count",
|
key="voltage_swell_l2_count",
|
||||||
translation_key="voltage_swell_l2_count",
|
translation_key="voltage_swell_l2_count",
|
||||||
obis_reference=obis_references.VOLTAGE_SWELL_L2_COUNT,
|
obis_reference="VOLTAGE_SWELL_L2_COUNT",
|
||||||
dsmr_versions={"2.2", "4", "5", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5L"},
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -247,7 +246,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="voltage_swell_l3_count",
|
key="voltage_swell_l3_count",
|
||||||
translation_key="voltage_swell_l3_count",
|
translation_key="voltage_swell_l3_count",
|
||||||
obis_reference=obis_references.VOLTAGE_SWELL_L3_COUNT,
|
obis_reference="VOLTAGE_SWELL_L3_COUNT",
|
||||||
dsmr_versions={"2.2", "4", "5", "5L"},
|
dsmr_versions={"2.2", "4", "5", "5L"},
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -255,7 +254,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_voltage_l1",
|
key="instantaneous_voltage_l1",
|
||||||
translation_key="instantaneous_voltage_l1",
|
translation_key="instantaneous_voltage_l1",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_VOLTAGE_L1,
|
obis_reference="INSTANTANEOUS_VOLTAGE_L1",
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -264,7 +263,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_voltage_l2",
|
key="instantaneous_voltage_l2",
|
||||||
translation_key="instantaneous_voltage_l2",
|
translation_key="instantaneous_voltage_l2",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_VOLTAGE_L2,
|
obis_reference="INSTANTANEOUS_VOLTAGE_L2",
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -273,7 +272,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_voltage_l3",
|
key="instantaneous_voltage_l3",
|
||||||
translation_key="instantaneous_voltage_l3",
|
translation_key="instantaneous_voltage_l3",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_VOLTAGE_L3,
|
obis_reference="INSTANTANEOUS_VOLTAGE_L3",
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -282,7 +281,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_current_l1",
|
key="instantaneous_current_l1",
|
||||||
translation_key="instantaneous_current_l1",
|
translation_key="instantaneous_current_l1",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_CURRENT_L1,
|
obis_reference="INSTANTANEOUS_CURRENT_L1",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -291,7 +290,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_current_l2",
|
key="instantaneous_current_l2",
|
||||||
translation_key="instantaneous_current_l2",
|
translation_key="instantaneous_current_l2",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_CURRENT_L2,
|
obis_reference="INSTANTANEOUS_CURRENT_L2",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -300,7 +299,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="instantaneous_current_l3",
|
key="instantaneous_current_l3",
|
||||||
translation_key="instantaneous_current_l3",
|
translation_key="instantaneous_current_l3",
|
||||||
obis_reference=obis_references.INSTANTANEOUS_CURRENT_L3,
|
obis_reference="INSTANTANEOUS_CURRENT_L3",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -309,7 +308,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="belgium_max_power_per_phase",
|
key="belgium_max_power_per_phase",
|
||||||
translation_key="max_power_per_phase",
|
translation_key="max_power_per_phase",
|
||||||
obis_reference=obis_references.BELGIUM_MAX_POWER_PER_PHASE,
|
obis_reference="ACTUAL_TRESHOLD_ELECTRICITY",
|
||||||
dsmr_versions={"5B"},
|
dsmr_versions={"5B"},
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -319,7 +318,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="belgium_max_current_per_phase",
|
key="belgium_max_current_per_phase",
|
||||||
translation_key="max_current_per_phase",
|
translation_key="max_current_per_phase",
|
||||||
obis_reference=obis_references.BELGIUM_MAX_CURRENT_PER_PHASE,
|
obis_reference="BELGIUM_MAX_CURRENT_PER_PHASE",
|
||||||
dsmr_versions={"5B"},
|
dsmr_versions={"5B"},
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -329,7 +328,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="electricity_imported_total",
|
key="electricity_imported_total",
|
||||||
translation_key="electricity_imported_total",
|
translation_key="electricity_imported_total",
|
||||||
obis_reference=obis_references.ELECTRICITY_IMPORTED_TOTAL,
|
obis_reference="ELECTRICITY_IMPORTED_TOTAL",
|
||||||
dsmr_versions={"5L", "5S", "Q3D"},
|
dsmr_versions={"5L", "5S", "Q3D"},
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
@ -337,7 +336,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="electricity_exported_total",
|
key="electricity_exported_total",
|
||||||
translation_key="electricity_exported_total",
|
translation_key="electricity_exported_total",
|
||||||
obis_reference=obis_references.ELECTRICITY_EXPORTED_TOTAL,
|
obis_reference="ELECTRICITY_EXPORTED_TOTAL",
|
||||||
dsmr_versions={"5L", "5S", "Q3D"},
|
dsmr_versions={"5L", "5S", "Q3D"},
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
@ -345,7 +344,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="belgium_current_average_demand",
|
key="belgium_current_average_demand",
|
||||||
translation_key="current_average_demand",
|
translation_key="current_average_demand",
|
||||||
obis_reference=obis_references.BELGIUM_CURRENT_AVERAGE_DEMAND,
|
obis_reference="BELGIUM_CURRENT_AVERAGE_DEMAND",
|
||||||
dsmr_versions={"5B"},
|
dsmr_versions={"5B"},
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -353,7 +352,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="belgium_maximum_demand_current_month",
|
key="belgium_maximum_demand_current_month",
|
||||||
translation_key="maximum_demand_current_month",
|
translation_key="maximum_demand_current_month",
|
||||||
obis_reference=obis_references.BELGIUM_MAXIMUM_DEMAND_MONTH,
|
obis_reference="BELGIUM_MAXIMUM_DEMAND_MONTH",
|
||||||
dsmr_versions={"5B"},
|
dsmr_versions={"5B"},
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
@ -361,7 +360,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="hourly_gas_meter_reading",
|
key="hourly_gas_meter_reading",
|
||||||
translation_key="gas_meter_reading",
|
translation_key="gas_meter_reading",
|
||||||
obis_reference=obis_references.HOURLY_GAS_METER_READING,
|
obis_reference="HOURLY_GAS_METER_READING",
|
||||||
dsmr_versions={"4", "5", "5L"},
|
dsmr_versions={"4", "5", "5L"},
|
||||||
is_gas=True,
|
is_gas=True,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
|
@ -370,7 +369,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
||||||
DSMRSensorEntityDescription(
|
DSMRSensorEntityDescription(
|
||||||
key="gas_meter_reading",
|
key="gas_meter_reading",
|
||||||
translation_key="gas_meter_reading",
|
translation_key="gas_meter_reading",
|
||||||
obis_reference=obis_references.GAS_METER_READING,
|
obis_reference="GAS_METER_READING",
|
||||||
dsmr_versions={"2.2"},
|
dsmr_versions={"2.2"},
|
||||||
is_gas=True,
|
is_gas=True,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
|
@ -383,36 +382,20 @@ def create_mbus_entity(
|
||||||
mbus: int, mtype: int, telegram: Telegram
|
mbus: int, mtype: int, telegram: Telegram
|
||||||
) -> DSMRSensorEntityDescription | None:
|
) -> DSMRSensorEntityDescription | None:
|
||||||
"""Create a new MBUS Entity."""
|
"""Create a new MBUS Entity."""
|
||||||
if (
|
if mtype == 3 and hasattr(telegram, f"BELGIUM_MBUS{mbus}_METER_READING2"):
|
||||||
mtype == 3
|
|
||||||
and (
|
|
||||||
obis_reference := getattr(
|
|
||||||
obis_references, f"BELGIUM_MBUS{mbus}_METER_READING2"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
in telegram
|
|
||||||
):
|
|
||||||
return DSMRSensorEntityDescription(
|
return DSMRSensorEntityDescription(
|
||||||
key=f"mbus{mbus}_gas_reading",
|
key=f"mbus{mbus}_gas_reading",
|
||||||
translation_key="gas_meter_reading",
|
translation_key="gas_meter_reading",
|
||||||
obis_reference=obis_reference,
|
obis_reference=f"BELGIUM_MBUS{mbus}_METER_READING2",
|
||||||
is_gas=True,
|
is_gas=True,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
)
|
)
|
||||||
if (
|
if mtype == 7 and (hasattr(telegram, f"BELGIUM_MBUS{mbus}_METER_READING1")):
|
||||||
mtype == 7
|
|
||||||
and (
|
|
||||||
obis_reference := getattr(
|
|
||||||
obis_references, f"BELGIUM_MBUS{mbus}_METER_READING1"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
in telegram
|
|
||||||
):
|
|
||||||
return DSMRSensorEntityDescription(
|
return DSMRSensorEntityDescription(
|
||||||
key=f"mbus{mbus}_water_reading",
|
key=f"mbus{mbus}_water_reading",
|
||||||
translation_key="water_meter_reading",
|
translation_key="water_meter_reading",
|
||||||
obis_reference=obis_reference,
|
obis_reference=f"BELGIUM_MBUS{mbus}_METER_READING1",
|
||||||
is_water=True,
|
is_water=True,
|
||||||
device_class=SensorDeviceClass.WATER,
|
device_class=SensorDeviceClass.WATER,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
@ -425,7 +408,7 @@ def device_class_and_uom(
|
||||||
entity_description: DSMRSensorEntityDescription,
|
entity_description: DSMRSensorEntityDescription,
|
||||||
) -> tuple[SensorDeviceClass | None, str | None]:
|
) -> tuple[SensorDeviceClass | None, str | None]:
|
||||||
"""Get native unit of measurement from telegram,."""
|
"""Get native unit of measurement from telegram,."""
|
||||||
dsmr_object = telegram[entity_description.obis_reference]
|
dsmr_object = getattr(telegram, entity_description.obis_reference)
|
||||||
uom: str | None = getattr(dsmr_object, "unit") or None
|
uom: str | None = getattr(dsmr_object, "unit") or None
|
||||||
with suppress(ValueError):
|
with suppress(ValueError):
|
||||||
if entity_description.device_class == SensorDeviceClass.GAS and (
|
if entity_description.device_class == SensorDeviceClass.GAS and (
|
||||||
|
@ -484,18 +467,15 @@ def create_mbus_entities(
|
||||||
entities = []
|
entities = []
|
||||||
for idx in range(1, 5):
|
for idx in range(1, 5):
|
||||||
if (
|
if (
|
||||||
device_type := getattr(obis_references, f"BELGIUM_MBUS{idx}_DEVICE_TYPE")
|
device_type := getattr(telegram, f"BELGIUM_MBUS{idx}_DEVICE_TYPE", None)
|
||||||
) not in telegram:
|
) is None:
|
||||||
continue
|
continue
|
||||||
if (type_ := int(telegram[device_type].value)) not in (3, 7):
|
if (type_ := int(device_type.value)) not in (3, 7):
|
||||||
continue
|
continue
|
||||||
if (
|
if identifier := getattr(
|
||||||
identifier := getattr(
|
telegram, f"BELGIUM_MBUS{idx}_EQUIPMENT_IDENTIFIER", None
|
||||||
obis_references,
|
):
|
||||||
f"BELGIUM_MBUS{idx}_EQUIPMENT_IDENTIFIER",
|
serial_ = identifier.value
|
||||||
)
|
|
||||||
) in telegram:
|
|
||||||
serial_ = telegram[identifier].value
|
|
||||||
rename_old_gas_to_mbus(hass, entry, serial_)
|
rename_old_gas_to_mbus(hass, entry, serial_)
|
||||||
else:
|
else:
|
||||||
serial_ = ""
|
serial_ = ""
|
||||||
|
@ -547,7 +527,7 @@ async def async_setup_entry(
|
||||||
or dsmr_version in description.dsmr_versions
|
or dsmr_version in description.dsmr_versions
|
||||||
)
|
)
|
||||||
and (not description.is_gas or CONF_SERIAL_ID_GAS in entry.data)
|
and (not description.is_gas or CONF_SERIAL_ID_GAS in entry.data)
|
||||||
and description.obis_reference in telegram
|
and hasattr(telegram, description.obis_reference)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
@ -756,21 +736,21 @@ class DSMREntity(SensorEntity):
|
||||||
"""Update data."""
|
"""Update data."""
|
||||||
self.telegram = telegram
|
self.telegram = telegram
|
||||||
if self.hass and (
|
if self.hass and (
|
||||||
telegram is None or self.entity_description.obis_reference in telegram
|
telegram is None
|
||||||
|
or hasattr(telegram, self.entity_description.obis_reference)
|
||||||
):
|
):
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
def get_dsmr_object_attr(self, attribute: str) -> str | None:
|
def get_dsmr_object_attr(self, attribute: str) -> str | None:
|
||||||
"""Read attribute from last received telegram for this DSMR object."""
|
"""Read attribute from last received telegram for this DSMR object."""
|
||||||
# Make sure telegram contains an object for this entities obis
|
# Make sure telegram contains an object for this entities obis
|
||||||
if (
|
if self.telegram is None or not hasattr(
|
||||||
self.telegram is None
|
self.telegram, self.entity_description.obis_reference
|
||||||
or self.entity_description.obis_reference not in self.telegram
|
|
||||||
):
|
):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Get the attribute value if the object has it
|
# Get the attribute value if the object has it
|
||||||
dsmr_object = self.telegram[self.entity_description.obis_reference]
|
dsmr_object = getattr(self.telegram, self.entity_description.obis_reference)
|
||||||
attr: str | None = getattr(dsmr_object, attribute)
|
attr: str | None = getattr(dsmr_object, attribute)
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
|
@ -786,10 +766,7 @@ class DSMREntity(SensorEntity):
|
||||||
if (value := self.get_dsmr_object_attr("value")) is None:
|
if (value := self.get_dsmr_object_attr("value")) is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if (
|
if self.entity_description.obis_reference == "ELECTRICITY_ACTIVE_TARIFF":
|
||||||
self.entity_description.obis_reference
|
|
||||||
== obis_references.ELECTRICITY_ACTIVE_TARIFF
|
|
||||||
):
|
|
||||||
return self.translate_tariff(value, self._entry.data[CONF_DSMR_VERSION])
|
return self.translate_tariff(value, self._entry.data[CONF_DSMR_VERSION])
|
||||||
|
|
||||||
with suppress(TypeError):
|
with suppress(TypeError):
|
||||||
|
|
|
@ -68,7 +68,7 @@ async def test_migrate_gas_to_mbus(
|
||||||
telegram = Telegram()
|
telegram = Telegram()
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE,
|
BELGIUM_MBUS1_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
CosemObject((0, 1), [{"value": "003", "unit": ""}]),
|
||||||
"BELGIUM_MBUS1_DEVICE_TYPE",
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
|
|
@ -11,6 +11,7 @@ from decimal import Decimal
|
||||||
from itertools import chain, repeat
|
from itertools import chain, repeat
|
||||||
from unittest.mock import DEFAULT, MagicMock
|
from unittest.mock import DEFAULT, MagicMock
|
||||||
|
|
||||||
|
from dsmr_parser import obis_references
|
||||||
from dsmr_parser.obis_references import (
|
from dsmr_parser.obis_references import (
|
||||||
BELGIUM_CURRENT_AVERAGE_DEMAND,
|
BELGIUM_CURRENT_AVERAGE_DEMAND,
|
||||||
BELGIUM_MAXIMUM_DEMAND_MONTH,
|
BELGIUM_MAXIMUM_DEMAND_MONTH,
|
||||||
|
@ -40,6 +41,7 @@ from dsmr_parser.obis_references import (
|
||||||
from dsmr_parser.objects import CosemObject, MBusObject, Telegram
|
from dsmr_parser.objects import CosemObject, MBusObject, Telegram
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.components.dsmr.sensor import SENSORS
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
ATTR_OPTIONS,
|
ATTR_OPTIONS,
|
||||||
ATTR_STATE_CLASS,
|
ATTR_STATE_CLASS,
|
||||||
|
@ -585,7 +587,7 @@ async def test_belgian_meter(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE,
|
BELGIUM_MBUS2_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
CosemObject((0, 2), [{"value": "007", "unit": ""}]),
|
||||||
"BELGIUM_MBUS2_DEVICE_TYPE",
|
"BELGIUM_MBUS2_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -609,7 +611,7 @@ async def test_belgian_meter(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE,
|
BELGIUM_MBUS3_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
CosemObject((0, 3), [{"value": "003", "unit": ""}]),
|
||||||
"BELGIUM_MBUS3_DEVICE_TYPE",
|
"BELGIUM_MBUS3_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -633,7 +635,7 @@ async def test_belgian_meter(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE,
|
BELGIUM_MBUS4_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
CosemObject((0, 4), [{"value": "007", "unit": ""}]),
|
||||||
"BELGIUM_MBUS4_DEVICE_TYPE",
|
"BELGIUM_MBUS4_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -776,7 +778,7 @@ async def test_belgian_meter_alt(
|
||||||
telegram = Telegram()
|
telegram = Telegram()
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE,
|
BELGIUM_MBUS1_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
CosemObject((0, 1), [{"value": "007", "unit": ""}]),
|
||||||
"BELGIUM_MBUS1_DEVICE_TYPE",
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -785,7 +787,7 @@ async def test_belgian_meter_alt(
|
||||||
(0, 1),
|
(0, 1),
|
||||||
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
[{"value": "37464C4F32313139303333373331", "unit": ""}],
|
||||||
),
|
),
|
||||||
"BELGIUM_MBUS1_DEVICE_TYPE",
|
"BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS1_METER_READING1,
|
BELGIUM_MBUS1_METER_READING1,
|
||||||
|
@ -800,7 +802,7 @@ async def test_belgian_meter_alt(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE,
|
BELGIUM_MBUS2_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
CosemObject((0, 2), [{"value": "003", "unit": ""}]),
|
||||||
"BELGIUM_MBUS2_DEVICE_TYPE",
|
"BELGIUM_MBUS2_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -820,11 +822,11 @@ async def test_belgian_meter_alt(
|
||||||
{"value": Decimal(678.901), "unit": "m3"},
|
{"value": Decimal(678.901), "unit": "m3"},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
BELGIUM_MBUS2_METER_READING2,
|
"BELGIUM_MBUS2_METER_READING2",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE,
|
BELGIUM_MBUS3_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
CosemObject((0, 3), [{"value": "007", "unit": ""}]),
|
||||||
"BELGIUM_MBUS3_DEVICE_TYPE",
|
"BELGIUM_MBUS3_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -848,7 +850,7 @@ async def test_belgian_meter_alt(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE,
|
BELGIUM_MBUS4_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
CosemObject((0, 4), [{"value": "003", "unit": ""}]),
|
||||||
"BELGIUM_MBUS4_DEVICE_TYPE",
|
"BELGIUM_MBUS4_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -969,7 +971,7 @@ async def test_belgian_meter_mbus(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS1_DEVICE_TYPE,
|
BELGIUM_MBUS1_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "006", "unit": ""}]),
|
CosemObject((0, 1), [{"value": "006", "unit": ""}]),
|
||||||
"BELGIUM_MBUS1_DEVICE_TYPE",
|
"BELGIUM_MBUS1_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -982,7 +984,7 @@ async def test_belgian_meter_mbus(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS2_DEVICE_TYPE,
|
BELGIUM_MBUS2_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "003", "unit": ""}]),
|
CosemObject((0, 2), [{"value": "003", "unit": ""}]),
|
||||||
"BELGIUM_MBUS2_DEVICE_TYPE",
|
"BELGIUM_MBUS2_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -995,7 +997,7 @@ async def test_belgian_meter_mbus(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS3_DEVICE_TYPE,
|
BELGIUM_MBUS3_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
CosemObject((0, 3), [{"value": "007", "unit": ""}]),
|
||||||
"BELGIUM_MBUS3_DEVICE_TYPE",
|
"BELGIUM_MBUS3_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -1019,7 +1021,7 @@ async def test_belgian_meter_mbus(
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
BELGIUM_MBUS4_DEVICE_TYPE,
|
BELGIUM_MBUS4_DEVICE_TYPE,
|
||||||
CosemObject((0, 0), [{"value": "007", "unit": ""}]),
|
CosemObject((0, 4), [{"value": "007", "unit": ""}]),
|
||||||
"BELGIUM_MBUS4_DEVICE_TYPE",
|
"BELGIUM_MBUS4_DEVICE_TYPE",
|
||||||
)
|
)
|
||||||
telegram.add(
|
telegram.add(
|
||||||
|
@ -1518,3 +1520,9 @@ async def test_gas_meter_providing_energy_reading(
|
||||||
gas_consumption.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
gas_consumption.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== UnitOfEnergy.GIGA_JOULE
|
== UnitOfEnergy.GIGA_JOULE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_all_obis_references_exists():
|
||||||
|
"""Verify that all attributes exist by name in database."""
|
||||||
|
for sensor in SENSORS:
|
||||||
|
assert hasattr(obis_references, sensor.obis_reference)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue