ESPHome 2025.5.2
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
sun_sensor.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace sun {
9
14
16 public:
17 void set_parent(Sun *parent) { parent_ = parent; }
19 void dump_config() override;
20 void update() override {
21 double val;
22 switch (this->type_) {
24 val = this->parent_->elevation();
25 break;
27 val = this->parent_->azimuth();
28 break;
29 default:
30 return;
31 }
32 this->publish_state(val);
33 }
34
35 protected:
38};
39
40} // namespace sun
41} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
Base-class for all sensors.
Definition sensor.h:57
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:39
double elevation()
Definition sun.cpp:318
double azimuth()
Definition sun.cpp:319
void set_type(SensorType type)
Definition sun_sensor.h:18
void dump_config() override
Definition sun_sensor.cpp:9
void set_parent(Sun *parent)
Definition sun_sensor.h:17
void update() override
Definition sun_sensor.h:20
uint8_t type
mopeka_std_values val[4]
@ SUN_SENSOR_ELEVATION
Definition sun_sensor.h:11
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7