mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
Fix validation of addressable light IDs (#2588)
This commit is contained in:
parent
f408f074c4
commit
07a9cb910f
2 changed files with 8 additions and 3 deletions
|
@ -22,6 +22,12 @@ using ESPColor ESPDEPRECATED("esphome::light::ESPColor is deprecated, use esphom
|
||||||
/// 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);
|
||||||
|
|
||||||
|
/// Use a custom state class for addressable lights, to allow type system to discriminate between addressable and
|
||||||
|
/// non-addressable lights.
|
||||||
|
class AddressableLightState : public LightState {
|
||||||
|
using LightState::LightState;
|
||||||
|
};
|
||||||
|
|
||||||
class AddressableLight : public LightOutput, public Component {
|
class AddressableLight : public LightOutput, public Component {
|
||||||
public:
|
public:
|
||||||
virtual int32_t size() const = 0;
|
virtual int32_t size() const = 0;
|
||||||
|
|
|
@ -4,10 +4,9 @@ from esphome import automation
|
||||||
# Base
|
# Base
|
||||||
light_ns = cg.esphome_ns.namespace("light")
|
light_ns = cg.esphome_ns.namespace("light")
|
||||||
LightState = light_ns.class_("LightState", cg.EntityBase, cg.Component)
|
LightState = light_ns.class_("LightState", cg.EntityBase, cg.Component)
|
||||||
# Fake class for addressable lights
|
AddressableLightState = light_ns.class_("AddressableLightState", LightState)
|
||||||
AddressableLightState = light_ns.class_("LightState", LightState)
|
|
||||||
LightOutput = light_ns.class_("LightOutput")
|
LightOutput = light_ns.class_("LightOutput")
|
||||||
AddressableLight = light_ns.class_("AddressableLight", cg.Component)
|
AddressableLight = light_ns.class_("AddressableLight", LightOutput, cg.Component)
|
||||||
AddressableLightRef = AddressableLight.operator("ref")
|
AddressableLightRef = AddressableLight.operator("ref")
|
||||||
|
|
||||||
Color = cg.esphome_ns.class_("Color")
|
Color = cg.esphome_ns.class_("Color")
|
||||||
|
|
Loading…
Reference in a new issue