5 namespace duty_time_sensor {
7 static const char *
const TAG =
"duty_time_sensor";
9 #ifdef USE_BINARY_SENSOR 31 if (this->
func_ ==
nullptr)
59 const uint32_t now =
millis();
64 const uint32_t ms = tm % 1000;
67 this->last_time_ = now - ms;
71 this->last_time_ = ms;
75 const uint32_t turn_on_ms = now - this->
edge_time_;
97 ESP_LOGCONFIG(TAG,
"Duty Time:");
99 ESP_LOGCONFIG(TAG,
" Restore: %s", ONOFF(this->
restore_));
100 LOG_SENSOR(
" ",
"Duty Time Sensor:",
this);
ESPPreferenceObject pref_
sensor::Sensor * last_duty_time_sensor_
void dump_config() override
uint32_t IRAM_ATTR HOT millis()
float state
This member variable stores the last state that has passed through all filters.
ESPPreferences * global_preferences
void publish_state(float state)
Publish a new state to the front-end.
virtual uint32_t get_update_interval() const
Get the update interval in ms of this sensor.
std::function< bool()> func_
void publish_and_save_(uint32_t sec, uint32_t ms)
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
void add_on_state_callback(std::function< void(bool)> &&callback)
Add a callback to be notified of state changes.
void set_sensor(binary_sensor::BinarySensor *sensor)
void process_state_(bool state)
Implementation of SPI Controller mode.
void set_value_(uint32_t sec)
Base class for all binary_sensor-type classes.
uint32_t get_object_id_hash()
esphome::sensor::Sensor * sensor