From a223034e57933111a7a1e2f6791d4d70dea06ce1 Mon Sep 17 00:00:00 2001 From: minomy13 Date: Wed, 13 Nov 2024 16:06:57 +0100 Subject: [PATCH] added config option for internal pull-up to python code --- esphome/components/dht/sensor.py | 4 ++++ esphome/const.py | 1 + 2 files changed, 5 insertions(+) diff --git a/esphome/components/dht/sensor.py b/esphome/components/dht/sensor.py index da92a97e1f..f32f822fa3 100644 --- a/esphome/components/dht/sensor.py +++ b/esphome/components/dht/sensor.py @@ -5,6 +5,7 @@ from esphome.components import sensor from esphome.const import ( CONF_HUMIDITY, CONF_ID, + CONF_INTERNAL_PULLUP, CONF_MODEL, CONF_PIN, CONF_TEMPERATURE, @@ -50,6 +51,7 @@ CONFIG_SCHEMA = cv.Schema( cv.Optional(CONF_MODEL, default="auto detect"): cv.enum( DHT_MODELS, upper=True, space="_" ), + cv.Optional(CONF_INTERNAL_PULLUP, default=True): cv.boolean, } ).extend(cv.polling_component_schema("60s")) @@ -68,4 +70,6 @@ async def to_code(config): sens = await sensor.new_sensor(config[CONF_HUMIDITY]) cg.add(var.set_humidity_sensor(sens)) + cg.add(var.set_internal_pullup(config[CONF_INTERNAL_PULLUP])) + cg.add(var.set_dht_model(config[CONF_MODEL])) diff --git a/esphome/const.py b/esphome/const.py index d42ee5ee72..b8b34045c7 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -411,6 +411,7 @@ CONF_INTERLOCK = "interlock" CONF_INTERNAL = "internal" CONF_INTERNAL_FILTER = "internal_filter" CONF_INTERNAL_FILTER_MODE = "internal_filter_mode" +CONF_INTERNAL_PULLUP = "use_internal_pullup" CONF_INTERNAL_TEMPERATURE = "internal_temperature" CONF_INTERRUPT = "interrupt" CONF_INTERRUPT_PIN = "interrupt_pin"