Dear Community,
i got the Athom 15W preflashed with tasmota from Aliexpress.
After flashing esphome I relaized that the warm white and cold white channel are split into color temperatur and brightness.
I have not much experience seting up the code in c++ to achive the correct behaiviour.
Here is what collected till now:
Tasmota Template: https://templates.blakadder.com/athom_LB01-15W-E27.html
Athom 15W GPIO Layout:
RGB: Red: 4, Green: 12, Blue: 14
WW: CT: 13, Brightness: 5
Some one on github already wrote a coustem light componet but that one is currently missing the RGB part.
The ESPFile yaml file could probably look something like this:
output:
- platform: esp8266_pwm
pin: GPIO13
id: out_cw
- platform: esp8266_pwm
pin: GPIO5
id: out_b
- platform: esp8266_pwm
pin: GPIO4
id: out_red
- platform: esp8266_pwm
pin: GPIO12
id: out_green
- platform: esp8266_pwm
pin: GPIO14
id: out_blue
light:
- platform: custom
lambda: |-
auto light_out = new Athom15w(id(out_cw),id(out_b),id(out_red),id(out_green),id(out_blue));
App.register_component(light_out);
return {light_out};
lights:
- name: "${friendly_name}"
gamma_correct: 0
Now comes the c++ part I don’t know how to setup correctly (athom_15w.h)
#pragma once
#include "esphome.h"
class Athom15w : public Component, public LightOutput {
public:
Athom15w(FloatOutput *cw_white_color, FloatOutput *brightness)
{
cw_white_color_ = cw_white_color;
brightness_ = brightness;
cold_white_temperature_ = 175;
warm_white_temperature_ = 333;
constant_brightness_ = true;
}
LightTraits get_traits() override {
auto traits = light::LightTraits();
traits.set_supports_brightness(true);
traits.set_supports_rgb(false);
traits.set_supports_rgb_white_value(false);
traits.set_supports_color_temperature(true);
traits.set_min_mireds(this->cold_white_temperature_);
traits.set_max_mireds(this->warm_white_temperature_);
return traits;
}
void write_state(LightState *state) override {
float brightness, cwhite, wwhite;
state->current_values_as_cwww(&cwhite, &wwhite, this->constant_brightness_);
// ESP_LOGD("custom", "The value cwhite: %f", cwhite);
// ESP_LOGD("custom", "The value wwhite: %f", wwhite);
state->current_values_as_brightness(&brightness);
// ESP_LOGD("custom", "The value brightness: %f", brightness);
this->cw_white_color_->set_level(cwhite+(1-brightness));
this->brightness_->set_level(brightness);
}
protected:
FloatOutput *cw_white_color_;
FloatOutput *brightness_;
float cold_white_temperature_;
float warm_white_temperature_;
bool constant_brightness_;
};
Can someone help to correct the code?
Thank you.