ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
uptime_seconds_sensor.cpp
Go to the documentation of this file.
2
3#include "esphome/core/hal.h"
4#include "esphome/core/log.h"
5
6namespace esphome::uptime {
7
8static const char *const TAG = "uptime.sensor";
9
11 const uint64_t uptime = millis_64();
12 const uint64_t seconds_int = uptime / 1000ULL;
13 const float seconds = float(seconds_int) + (uptime % 1000ULL) / 1000.0f;
14 this->publish_state(seconds);
15}
18 LOG_SENSOR("", "Uptime Sensor", this);
19 ESP_LOGCONFIG(TAG, " Type: Seconds");
20}
21
22} // namespace esphome::uptime
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:65
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:29
uint64_t HOT millis_64()
Definition core.cpp:26