8#ifdef USE_BINARY_SENSOR
14void DutyTimeSensor::start() {
19void DutyTimeSensor::stop() {
24void DutyTimeSensor::update() {
29void DutyTimeSensor::loop() {
30 if (this->
func_ ==
nullptr)
66 this->last_time_ = now - ms;
70 this->last_time_ = ms;
73 PUBLISH_STATE(this->last_duty_time_sensor_, (now - this->
edge_time_) * 1e-3f);
92void DutyTimeSensor::dump_config() {
95 " Update Interval: %" PRId32
"ms\n"
98 LOG_SENSOR(
" ",
"Duty Time Sensor:",
this);
99 LOG_SENSOR(
" ",
"Last Duty Time Sensor:", this->last_duty_time_sensor_);
virtual void setup()
Where the component's initialization should happen.
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
virtual uint32_t get_update_interval() const
Get the update interval in ms of this sensor.
void add_on_state_callback(F &&callback)
Base class for all binary_sensor-type classes.
std::function< bool()> func_
void publish_and_save_(uint32_t sec, uint32_t ms)
ESPPreferenceObject pref_
void process_state_(bool state)
void set_value_(uint32_t sec)
void publish_state(float state)
Publish a new state to the front-end.
float state
This member variable stores the last state that has passed through all filters.
ESPHOME_LOG_TAG(TAG, "duty_time_sensor")
uint32_t IRAM_ATTR HOT millis()