Expose thermal sensors in DSMR component

Adds the thermal MBUS id configuration option and the thermal sensor.
This commit is contained in:
Thom Wiggers 2024-10-01 13:00:53 +02:00
parent 68928aee7c
commit a9c04a241f
No known key found for this signature in database
GPG Key ID: 001BB0A7CE26E363
3 changed files with 12 additions and 1 deletions

View File

@ -20,6 +20,7 @@ CONF_DECRYPTION_KEY = "decryption_key"
CONF_DSMR_ID = "dsmr_id" CONF_DSMR_ID = "dsmr_id"
CONF_GAS_MBUS_ID = "gas_mbus_id" CONF_GAS_MBUS_ID = "gas_mbus_id"
CONF_WATER_MBUS_ID = "water_mbus_id" CONF_WATER_MBUS_ID = "water_mbus_id"
CONF_THERMAL_MBUS_ID = "thermal_mbus_id"
CONF_MAX_TELEGRAM_LENGTH = "max_telegram_length" CONF_MAX_TELEGRAM_LENGTH = "max_telegram_length"
CONF_REQUEST_INTERVAL = "request_interval" CONF_REQUEST_INTERVAL = "request_interval"
CONF_REQUEST_PIN = "request_pin" CONF_REQUEST_PIN = "request_pin"
@ -55,6 +56,7 @@ CONFIG_SCHEMA = cv.All(
cv.Optional(CONF_CRC_CHECK, default=True): cv.boolean, cv.Optional(CONF_CRC_CHECK, default=True): cv.boolean,
cv.Optional(CONF_GAS_MBUS_ID, default=1): cv.int_, cv.Optional(CONF_GAS_MBUS_ID, default=1): cv.int_,
cv.Optional(CONF_WATER_MBUS_ID, default=2): cv.int_, cv.Optional(CONF_WATER_MBUS_ID, default=2): cv.int_,
cv.Optional(CONF_THERMAL_MBUS_ID, default=3): cv.int_,
cv.Optional(CONF_MAX_TELEGRAM_LENGTH, default=1500): cv.int_, cv.Optional(CONF_MAX_TELEGRAM_LENGTH, default=1500): cv.int_,
cv.Optional(CONF_REQUEST_PIN): pins.gpio_output_pin_schema, cv.Optional(CONF_REQUEST_PIN): pins.gpio_output_pin_schema,
cv.Optional( cv.Optional(
@ -85,9 +87,10 @@ async def to_code(config):
cg.add_build_flag("-DDSMR_GAS_MBUS_ID=" + str(config[CONF_GAS_MBUS_ID])) cg.add_build_flag("-DDSMR_GAS_MBUS_ID=" + str(config[CONF_GAS_MBUS_ID]))
cg.add_build_flag("-DDSMR_WATER_MBUS_ID=" + str(config[CONF_WATER_MBUS_ID])) cg.add_build_flag("-DDSMR_WATER_MBUS_ID=" + str(config[CONF_WATER_MBUS_ID]))
cg.add_build_flag("-DDSMR_THERMAL_MBUS_ID=" + str(config[CONF_THERMAL_MBUS_ID))
# DSMR Parser # DSMR Parser
cg.add_library("glmnet/Dsmr", "0.8") cg.add_library("glmnet/Dsmr", "0.9")
# Crypto # Crypto
cg.add_library("rweather/Crypto", "0.4.0") cg.add_library("rweather/Crypto", "0.4.0")

View File

@ -13,6 +13,7 @@ from esphome.const import (
STATE_CLASS_TOTAL_INCREASING, STATE_CLASS_TOTAL_INCREASING,
UNIT_AMPERE, UNIT_AMPERE,
UNIT_CUBIC_METER, UNIT_CUBIC_METER,
UNIT_GIGAJOULE,
UNIT_KILOWATT, UNIT_KILOWATT,
UNIT_KILOWATT_HOURS, UNIT_KILOWATT_HOURS,
UNIT_KILOVOLT_AMPS_REACTIVE_HOURS, UNIT_KILOVOLT_AMPS_REACTIVE_HOURS,
@ -237,6 +238,12 @@ CONFIG_SCHEMA = cv.Schema(
device_class=DEVICE_CLASS_GAS, device_class=DEVICE_CLASS_GAS,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=STATE_CLASS_TOTAL_INCREASING,
), ),
cv.Optional("thermal_delivered"): sensor.sensor_schema(
unit_of_measurement=UNIT_GIGAJOULE,
accuracy_decimals=3,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
cv.Optional("water_delivered"): sensor.sensor_schema( cv.Optional("water_delivered"): sensor.sensor_schema(
unit_of_measurement=UNIT_CUBIC_METER, unit_of_measurement=UNIT_CUBIC_METER,
accuracy_decimals=3, accuracy_decimals=3,

View File

@ -1035,6 +1035,7 @@ UNIT_DEGREE_PER_SECOND = "°/s"
UNIT_DEGREES = "°" UNIT_DEGREES = "°"
UNIT_EMPTY = "" UNIT_EMPTY = ""
UNIT_G = "G" UNIT_G = "G"
UNIT_GIGAJOULE = "GJ"
UNIT_GRAMS_PER_CUBIC_METER = "g/m³" UNIT_GRAMS_PER_CUBIC_METER = "g/m³"
UNIT_HECTOPASCAL = "hPa" UNIT_HECTOPASCAL = "hPa"
UNIT_HERTZ = "Hz" UNIT_HERTZ = "Hz"