diff --git a/esphome/components/gp8211/__init__.py b/esphome/components/gp8211/__init__.py index 2c9cfadfc8..0609215346 100644 --- a/esphome/components/gp8211/__init__.py +++ b/esphome/components/gp8211/__init__.py @@ -28,7 +28,7 @@ CONFIG_SCHEMA = ( } ) .extend(cv.COMPONENT_SCHEMA) - .extend(i2c.i2c_device_schema(0x58)) # GP8211 I2C-Adresse + .extend(i2c.i2c_device_schema(0x58)) ) async def to_code(config): diff --git a/esphome/components/gp8211/gp8211.cpp b/esphome/components/gp8211/gp8211.cpp index 5d9ac92763..b35af96838 100644 --- a/esphome/components/gp8211/gp8211.cpp +++ b/esphome/components/gp8211/gp8211.cpp @@ -6,11 +6,10 @@ namespace gp8211 { static const char *const TAG = "gp8211"; -static const uint8_t RANGE_REGISTER = 0x01; // Register für die Spannungsrange +static const uint8_t RANGE_REGISTER = 0x01; void GP8211::setup() { - // Wähle den Spannungsmodus basierend auf der YAML-Konfiguration - uint8_t voltage_setting = (this->voltage_ == GP8211_VOLTAGE_10V) ? 0x77 : 0x55; // 0x77 für 0-10V, 0x55 für 0-5V + uint8_t voltage_setting = (this->voltage_ == GP8211_VOLTAGE_10V) ? 0x77 : 0x55; this->write_register(RANGE_REGISTER, &voltage_setting, 1); } diff --git a/esphome/components/gp8211/output/gp8211_output.cpp b/esphome/components/gp8211/output/gp8211_output.cpp index fcb93efdbf..3e1440b12d 100644 --- a/esphome/components/gp8211/output/gp8211_output.cpp +++ b/esphome/components/gp8211/output/gp8211_output.cpp @@ -13,14 +13,11 @@ void GP8211Output::dump_config() { } void GP8211Output::write_state(float state) { - // Ausgabe des ursprünglichen Helligkeitswerts von der Light-Komponente ESP_LOGD(TAG, "Original brightness state received from Light component: %.5f", state); - // Konvertiere den state (0.0 bis 1.0) in einen 15-Bit DAC-Wert (0 bis 32767) uint16_t value = static_cast(state * 32767); - ESP_LOGD(TAG, "Calculated DAC value: %u", value); // Ausgabe des berechneten Wertes zur Überprüfung - - // Sende den Wert an den DAC (2 Bytes) + ESP_LOGD(TAG, "Calculated DAC value: %u", value); + i2c::ErrorCode err = this->parent_->write_register(OUTPUT_REGISTER, (uint8_t *)&value, 2); if (err != i2c::ERROR_OK) {