1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-20 08:46:01 +00:00

Merge branch 'integration' into memory_api

This commit is contained in:
J. Nick Koston
2025-11-18 21:09:31 -06:00
27 changed files with 54 additions and 108 deletions

View File

@@ -1,8 +1,7 @@
#include "addressable_light.h" #include "addressable_light.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
namespace esphome { namespace esphome::light {
namespace light {
static const char *const TAG = "light.addressable"; static const char *const TAG = "light.addressable";
@@ -112,5 +111,4 @@ optional<LightColorValues> AddressableLightTransformer::apply() {
return {}; return {};
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -14,8 +14,7 @@
#include "esphome/components/power_supply/power_supply.h" #include "esphome/components/power_supply/power_supply.h"
#endif #endif
namespace esphome { namespace esphome::light {
namespace light {
/// Convert the color information from a `LightColorValues` object to a `Color` object (does not apply brightness). /// Convert the color information from a `LightColorValues` object to a `Color` object (does not apply brightness).
Color color_from_light_color_values(LightColorValues val); Color color_from_light_color_values(LightColorValues val);
@@ -116,5 +115,4 @@ class AddressableLightTransformer : public LightTransformer {
Color target_color_{}; Color target_color_{};
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -7,8 +7,7 @@
#include "esphome/components/light/light_state.h" #include "esphome/components/light/light_state.h"
#include "esphome/components/light/addressable_light.h" #include "esphome/components/light/addressable_light.h"
namespace esphome { namespace esphome::light {
namespace light {
inline static int16_t sin16_c(uint16_t theta) { inline static int16_t sin16_c(uint16_t theta) {
static const uint16_t BASE[] = {0, 6393, 12539, 18204, 23170, 27245, 30273, 32137}; static const uint16_t BASE[] = {0, 6393, 12539, 18204, 23170, 27245, 30273, 32137};
@@ -371,5 +370,4 @@ class AddressableFlickerEffect : public AddressableLightEffect {
uint8_t intensity_{13}; uint8_t intensity_{13};
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -3,8 +3,7 @@
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "addressable_light.h" #include "addressable_light.h"
namespace esphome { namespace esphome::light {
namespace light {
class AddressableLightWrapper : public light::AddressableLight { class AddressableLightWrapper : public light::AddressableLight {
public: public:
@@ -123,5 +122,4 @@ class AddressableLightWrapper : public light::AddressableLight {
ColorMode color_mode_{ColorMode::UNKNOWN}; ColorMode color_mode_{ColorMode::UNKNOWN};
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -1,8 +1,7 @@
#include "automation.h" #include "automation.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
namespace esphome { namespace esphome::light {
namespace light {
static const char *const TAG = "light.automation"; static const char *const TAG = "light.automation";
@@ -11,5 +10,4 @@ void addressableset_warn_about_scale(const char *field) {
field); field);
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -4,8 +4,7 @@
#include "light_state.h" #include "light_state.h"
#include "addressable_light.h" #include "addressable_light.h"
namespace esphome { namespace esphome::light {
namespace light {
enum class LimitMode { CLAMP, DO_NOTHING }; enum class LimitMode { CLAMP, DO_NOTHING };
@@ -216,5 +215,4 @@ template<typename... Ts> class AddressableSet : public Action<Ts...> {
} }
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -6,8 +6,7 @@
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "light_effect.h" #include "light_effect.h"
namespace esphome { namespace esphome::light {
namespace light {
inline static float random_cubic_float() { inline static float random_cubic_float() {
const float r = random_float() * 2.0f - 1.0f; const float r = random_float() * 2.0f - 1.0f;
@@ -235,5 +234,4 @@ class FlickerLightEffect : public LightEffect {
float alpha_{}; float alpha_{};
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -3,8 +3,7 @@
#include <cstdint> #include <cstdint>
#include "esphome/core/finite_set_mask.h" #include "esphome/core/finite_set_mask.h"
namespace esphome { namespace esphome::light {
namespace light {
/// Color capabilities are the various outputs that a light has and that can be independently controlled by the user. /// Color capabilities are the various outputs that a light has and that can be independently controlled by the user.
enum class ColorCapability : uint8_t { enum class ColorCapability : uint8_t {
@@ -210,5 +209,4 @@ inline bool has_capability(const ColorModeMask &mask, ColorCapability capability
return (mask.get_mask() & CAPABILITY_BITMASKS[capability_to_index(capability)]) != 0; return (mask.get_mask() & CAPABILITY_BITMASKS[capability_to_index(capability)]) != 0;
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -2,8 +2,7 @@
#include "light_color_values.h" #include "light_color_values.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
namespace esphome { namespace esphome::light {
namespace light {
void ESPColorCorrection::calculate_gamma_table(float gamma) { void ESPColorCorrection::calculate_gamma_table(float gamma) {
for (uint16_t i = 0; i < 256; i++) { for (uint16_t i = 0; i < 256; i++) {
@@ -23,5 +22,4 @@ void ESPColorCorrection::calculate_gamma_table(float gamma) {
} }
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -2,8 +2,7 @@
#include "esphome/core/color.h" #include "esphome/core/color.h"
namespace esphome { namespace esphome::light {
namespace light {
class ESPColorCorrection { class ESPColorCorrection {
public: public:
@@ -73,5 +72,4 @@ class ESPColorCorrection {
uint8_t local_brightness_{255}; uint8_t local_brightness_{255};
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -4,8 +4,7 @@
#include "esp_hsv_color.h" #include "esp_hsv_color.h"
#include "esp_color_correction.h" #include "esp_color_correction.h"
namespace esphome { namespace esphome::light {
namespace light {
class ESPColorSettable { class ESPColorSettable {
public: public:
@@ -106,5 +105,4 @@ class ESPColorView : public ESPColorSettable {
const ESPColorCorrection *color_correction_; const ESPColorCorrection *color_correction_;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -1,7 +1,6 @@
#include "esp_hsv_color.h" #include "esp_hsv_color.h"
namespace esphome { namespace esphome::light {
namespace light {
Color ESPHSVColor::to_rgb() const { Color ESPHSVColor::to_rgb() const {
// based on FastLED's hsv rainbow to rgb // based on FastLED's hsv rainbow to rgb
@@ -70,5 +69,4 @@ Color ESPHSVColor::to_rgb() const {
return rgb; return rgb;
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -3,8 +3,7 @@
#include "esphome/core/color.h" #include "esphome/core/color.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
namespace esphome { namespace esphome::light {
namespace light {
struct ESPHSVColor { struct ESPHSVColor {
union { union {
@@ -32,5 +31,4 @@ struct ESPHSVColor {
Color to_rgb() const; Color to_rgb() const;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -1,8 +1,7 @@
#include "esp_range_view.h" #include "esp_range_view.h"
#include "addressable_light.h" #include "addressable_light.h"
namespace esphome { namespace esphome::light {
namespace light {
int32_t HOT interpret_index(int32_t index, int32_t size) { int32_t HOT interpret_index(int32_t index, int32_t size) {
if (index < 0) if (index < 0)
@@ -92,5 +91,4 @@ ESPRangeView &ESPRangeView::operator=(const ESPRangeView &rhs) { // NOLINT
ESPColorView ESPRangeIterator::operator*() const { return this->range_.parent_->get(this->i_); } ESPColorView ESPRangeIterator::operator*() const { return this->range_.parent_->get(this->i_); }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -3,8 +3,7 @@
#include "esp_color_view.h" #include "esp_color_view.h"
#include "esp_hsv_color.h" #include "esp_hsv_color.h"
namespace esphome { namespace esphome::light {
namespace light {
int32_t interpret_index(int32_t index, int32_t size); int32_t interpret_index(int32_t index, int32_t size);
@@ -76,5 +75,4 @@ class ESPRangeIterator {
int32_t i_; int32_t i_;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -4,8 +4,7 @@
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/optional.h" #include "esphome/core/optional.h"
namespace esphome { namespace esphome::light {
namespace light {
static const char *const TAG = "light"; static const char *const TAG = "light";
@@ -647,5 +646,4 @@ LightCall &LightCall::set_rgbw(float red, float green, float blue, float white)
return *this; return *this;
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -4,8 +4,7 @@
#include "color_mode.h" #include "color_mode.h"
#include <cmath> #include <cmath>
namespace esphome { namespace esphome::light {
namespace light {
inline static uint8_t to_uint8_scale(float x) { return static_cast<uint8_t>(roundf(x * 255.0f)); } inline static uint8_t to_uint8_scale(float x) { return static_cast<uint8_t>(roundf(x * 255.0f)); }
@@ -310,5 +309,4 @@ class LightColorValues {
ColorMode color_mode_; ColorMode color_mode_;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -1,8 +1,7 @@
#include "light_effect.h" #include "light_effect.h"
#include "light_state.h" #include "light_state.h"
namespace esphome { namespace esphome::light {
namespace light {
uint32_t LightEffect::get_index() const { uint32_t LightEffect::get_index() const {
if (this->state_ == nullptr) { if (this->state_ == nullptr) {
@@ -32,5 +31,4 @@ uint32_t LightEffect::get_index_in_parent_() const {
return 0; // Not found return 0; // Not found
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -2,8 +2,7 @@
#include "esphome/core/component.h" #include "esphome/core/component.h"
namespace esphome { namespace esphome::light {
namespace light {
class LightState; class LightState;
@@ -55,5 +54,4 @@ class LightEffect {
uint32_t get_index_in_parent_() const; uint32_t get_index_in_parent_() const;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -3,8 +3,7 @@
#ifdef USE_JSON #ifdef USE_JSON
namespace esphome { namespace esphome::light {
namespace light {
// See https://www.home-assistant.io/integrations/light.mqtt/#json-schema for documentation on the schema // See https://www.home-assistant.io/integrations/light.mqtt/#json-schema for documentation on the schema
@@ -169,7 +168,6 @@ void LightJSONSchema::parse_json(LightState &state, LightCall &call, JsonObject
} }
} }
} // namespace light } // namespace esphome::light
} // namespace esphome
#endif #endif

View File

@@ -8,8 +8,7 @@
#include "light_call.h" #include "light_call.h"
#include "light_state.h" #include "light_state.h"
namespace esphome { namespace esphome::light {
namespace light {
class LightJSONSchema { class LightJSONSchema {
public: public:
@@ -22,7 +21,6 @@ class LightJSONSchema {
static void parse_color_json(LightState &state, LightCall &call, JsonObject root); static void parse_color_json(LightState &state, LightCall &call, JsonObject root);
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome
#endif #endif

View File

@@ -1,12 +1,10 @@
#include "light_output.h" #include "light_output.h"
#include "transformers.h" #include "transformers.h"
namespace esphome { namespace esphome::light {
namespace light {
std::unique_ptr<LightTransformer> LightOutput::create_default_transition() { std::unique_ptr<LightTransformer> LightOutput::create_default_transition() {
return make_unique<LightTransitionTransformer>(); return make_unique<LightTransitionTransformer>();
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -5,8 +5,7 @@
#include "light_state.h" #include "light_state.h"
#include "light_transformer.h" #include "light_transformer.h"
namespace esphome { namespace esphome::light {
namespace light {
/// Interface to write LightStates to hardware. /// Interface to write LightStates to hardware.
class LightOutput { class LightOutput {
@@ -29,5 +28,4 @@ class LightOutput {
virtual void write_state(LightState *state) = 0; virtual void write_state(LightState *state) = 0;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -5,8 +5,7 @@
#include "light_output.h" #include "light_output.h"
#include "transformers.h" #include "transformers.h"
namespace esphome { namespace esphome::light {
namespace light {
static const char *const TAG = "light"; static const char *const TAG = "light";
@@ -328,5 +327,4 @@ void LightState::save_remote_values_() {
this->rtc_.save(&saved); this->rtc_.save(&saved);
} }
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -15,8 +15,7 @@
#include <strings.h> #include <strings.h>
#include <vector> #include <vector>
namespace esphome { namespace esphome::light {
namespace light {
class LightOutput; class LightOutput;
@@ -301,5 +300,4 @@ class LightState : public EntityBase, public Component {
LightRestoreMode restore_mode_; LightRestoreMode restore_mode_;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -4,8 +4,7 @@
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "light_color_values.h" #include "light_color_values.h"
namespace esphome { namespace esphome::light {
namespace light {
/// Base class for all light color transformers, such as transitions or flashes. /// Base class for all light color transformers, such as transitions or flashes.
class LightTransformer { class LightTransformer {
@@ -59,5 +58,4 @@ class LightTransformer {
LightColorValues target_values_; LightColorValues target_values_;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome

View File

@@ -6,8 +6,7 @@
#include "light_state.h" #include "light_state.h"
#include "light_transformer.h" #include "light_transformer.h"
namespace esphome { namespace esphome::light {
namespace light {
class LightTransitionTransformer : public LightTransformer { class LightTransitionTransformer : public LightTransformer {
public: public:
@@ -118,5 +117,4 @@ class LightFlashTransformer : public LightTransformer {
bool begun_lightstate_restore_; bool begun_lightstate_restore_;
}; };
} // namespace light } // namespace esphome::light
} // namespace esphome