Hello,
I have an ESPHome device with a custom light component. This works well in HA 2021.7.4, however in HA 2021.8.1 there are no attributes for this custom light.
Below is the code for the custom light:
#pragma once
#include "esphome.h"
class KessilLight : public Component, public LightOutput {
public:
KessilLight(FloatOutput *brightness_output, FloatOutput *color_output)
{
brightness_output_ = brightness_output;
color_output_ = color_output;
}
LightTraits get_traits() override {
auto traits = LightTraits();
traits.set_supports_brightness(true);
traits.set_supports_color_temperature(false);
traits.set_supports_rgb(false);
traits.set_supports_rgb_white_value(true);
return traits;
}
void write_state(LightState *state) override {
float brightness, red, green, blue, white;
// use any of the provided current_values methods
state->current_values_as_rgbw(&red, &green, &blue, &white, this->color_interlock_);
state->current_values_as_brightness (&brightness);
white = white / brightness;
if (brightness == 0)
{
this->brightness_output_->set_level(0);
this->color_output_->set_level(0);
}
else
{
this->brightness_output_->set_level(brightness);
this->color_output_->set_level(white);
}
}
protected:
FloatOutput *brightness_output_;
FloatOutput *color_output_;
bool color_interlock_;
};
In the ESPHome config file the custom light is added as follow:
esphome:
name: reef_tank
comment: Reef Tank Contoller
platform: ESP8266
board: d1_mini
includes:
- kessil.h
...
light:
- platform: custom
lambda: |-
auto kessil_light = new KessilLight(id(reef_tank_light_brightness_pwm), id(reef_tank_light_color_pwm));
App.register_component(kessil_light);
return {kessil_light};
lights:
- name: "Reef Tank - Light"
id: reef_tank_light
gamma_correct: 1
In HA 2021.7.4 under the Developer Tools panel the following attributes are shown for this light:
supported_color_modes: rgbw
color_mode: rgbw
brightness: 181
hs_color: 0, 0
rgb_color: 255, 255, 255
rgbw_color: 255, 255, 255, 25
xy_color: 0.323, 0.329
white_value: 25
friendly_name: Reef Tank - Light
supported_features: 169
After upgrading to HA 2021.8.1 the following attributes are shown under the Developer Tools panel. Brightness and white cannot be adjusted anymore from the dashboard.
supported_color_modes:
color_mode: unknown
friendly_name: Reef Tank - Light
supported_features: 8
I restored a snapshot from HA 2021.7.4 and everything was working as expected. I tried to upgrade again to HA 2021.8.1 and end up with the same issue (no attributes for the custom light).
Could you please help understand if this is an issue with HA 2021.8.1 or if there is something I should change in the custom light to be able to adjust brightness and white from HA 2021.8.1?