mirror of
https://github.com/esphome/esphome.git
synced 2026-10-03 09:46:03 +00:00
[uptime] Skip the timestamp sensor source unless a timestamp sensor is configured (#18746)
This commit is contained in:
@@ -61,8 +61,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
if time_id_config := config.get(CONF_TIME_ID):
|
||||
time_id = await cg.get_variable(time_id_config)
|
||||
cg.add(var.set_time(time_id))
|
||||
cg.add_define("USE_UPTIME_TIMESTAMP")
|
||||
|
||||
|
||||
FILTER_SOURCE_FILES = filter_source_files_from_defines(
|
||||
{"uptime_timestamp_sensor.cpp": "USE_TIME"}
|
||||
{"uptime_timestamp_sensor.cpp": "USE_UPTIME_TIMESTAMP"}
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "uptime_timestamp_sensor.h"
|
||||
|
||||
#ifdef USE_TIME
|
||||
#ifdef USE_UPTIME_TIMESTAMP
|
||||
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
@@ -34,4 +34,4 @@ void UptimeTimestampSensor::dump_config() {
|
||||
|
||||
} // namespace esphome::uptime
|
||||
|
||||
#endif // USE_TIME
|
||||
#endif // USE_UPTIME_TIMESTAMP
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#ifdef USE_TIME
|
||||
#ifdef USE_UPTIME_TIMESTAMP
|
||||
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/time/real_time_clock.h"
|
||||
@@ -25,4 +25,4 @@ class UptimeTimestampSensor final : public sensor::Sensor, public Component {
|
||||
|
||||
} // namespace esphome::uptime
|
||||
|
||||
#endif // USE_TIME
|
||||
#endif // USE_UPTIME_TIMESTAMP
|
||||
|
||||
Reference in New Issue
Block a user