ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
sun_sensor.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::sun {
8
13
15 public:
16 void set_parent(Sun *parent) { parent_ = parent; }
18 void dump_config() override;
19 void update() override {
20 double val;
21 switch (this->type_) {
23 val = this->parent_->elevation();
24 break;
26 val = this->parent_->azimuth();
27 break;
28 default:
29 return;
30 }
31 this->publish_state(val);
32 }
33
34 protected:
37};
38
39} // namespace esphome::sun
This class simplifies creating components that periodically check a state.
Definition component.h:585
Base-class for all sensors.
Definition sensor.h:47
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68
double elevation()
Definition sun.cpp:321
double azimuth()
Definition sun.cpp:322
void set_type(SensorType type)
Definition sun_sensor.h:17
void dump_config() override
Definition sun_sensor.cpp:8
void set_parent(Sun *parent)
Definition sun_sensor.h:16
void update() override
Definition sun_sensor.h:19
uint16_t type
mopeka_std_values val[3]
@ SUN_SENSOR_ELEVATION
Definition sun_sensor.h:10