From 9578376f4662d9651613c10163018b9a2ce52ac9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 22 Mar 2026 16:51:01 -1000 Subject: [PATCH] [sensor] Remove USE_SENSOR_FILTER guard from SensorRawStateTrigger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add_on_raw_state_callback is always available now (delegates to callback_ without filters). SensorRawStateTrigger doesn't need the guard, and on_raw_value doesn't need to set USE_SENSOR_FILTER. Without filters raw == filtered, so the trigger fires with the correct value either way — no wasted RAM on filter infrastructure. --- esphome/components/sensor/__init__.py | 1 - esphome/components/sensor/automation.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/esphome/components/sensor/__init__.py b/esphome/components/sensor/__init__.py index 44ba87f86a..9f3c1484b0 100644 --- a/esphome/components/sensor/__init__.py +++ b/esphome/components/sensor/__init__.py @@ -901,7 +901,6 @@ async def _build_sensor_automations(var, config): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) await automation.build_automation(trigger, [(float, "x")], conf) for conf in config.get(CONF_ON_RAW_VALUE, []): - cg.add_define("USE_SENSOR_FILTER") trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) await automation.build_automation(trigger, [(float, "x")], conf) for conf in config.get(CONF_ON_VALUE_RANGE, []): diff --git a/esphome/components/sensor/automation.h b/esphome/components/sensor/automation.h index bcd2ca0f0d..b4de712727 100644 --- a/esphome/components/sensor/automation.h +++ b/esphome/components/sensor/automation.h @@ -13,14 +13,12 @@ class SensorStateTrigger : public Trigger { } }; -#ifdef USE_SENSOR_FILTER class SensorRawStateTrigger : public Trigger { public: explicit SensorRawStateTrigger(Sensor *parent) { parent->add_on_raw_state_callback([this](float value) { this->trigger(value); }); } }; -#endif template class SensorPublishAction : public Action { public: