ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
tfluna.h
Go to the documentation of this file.
1#pragma once
2
5#ifdef USE_SENSOR
7#endif
8#ifdef USE_TEXT_SENSOR
10#endif
11#ifdef USE_BUTTON
13#endif
15
16namespace esphome::tfluna {
17
18class TFLuna : public i2c::I2CDevice, public PollingComponent {
19#ifdef USE_SENSOR
20 SUB_SENSOR(distance)
21 SUB_SENSOR(temperature)
22 SUB_SENSOR(signal_strength)
23 SUB_SENSOR(timestamp)
24#endif
25#ifdef USE_TEXT_SENSOR
26 SUB_TEXT_SENSOR(version)
27#endif
28#ifdef USE_BUTTON
29 SUB_BUTTON(reset)
30 SUB_BUTTON(restart)
31#endif
32 public:
33 void setup() override;
34
35 float get_setup_priority() const override { return setup_priority::LATE; }
36
37 void dump_config() override;
38
39 void update() override;
40
41 void factory_reset();
42
43 void restart();
44
45 protected:
46 char version_[12] = "unknown";
47
48 uint16_t previous_timestamp_ = 0;
49
50 [[nodiscard]] bool read_data_();
51
52 void read_data_timeout_();
53
54 uint8_t attempt_ = 0;
55};
56
57} // namespace esphome::tfluna
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:514
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
uint16_t previous_timestamp_
Definition tfluna.h:48
uint16_t reset
Definition ina226.h:5
constexpr float LATE
For components that should be initialized at the very end of the setup process.
Definition component.h:59
uint16_t temperature
Definition sun_gtil2.cpp:12
uint16_t timestamp
Definition tt21100.cpp:2