add light component
This commit is contained in:
parent
ab11cdacd8
commit
70535f3467
@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
|
||||
"name": "ha-mqtt",
|
||||
"version": "1.4.2",
|
||||
"version": "1.5.0",
|
||||
"description": "Home Assistant classes for integration with MQTT auto discovery",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
14
src/ha.h
14
src/ha.h
@ -224,6 +224,20 @@ namespace Ha {
|
||||
}
|
||||
};
|
||||
|
||||
struct Light : Component, StatefulCommand {
|
||||
|
||||
Light(const char* name, const char* id, onMessage f = nullptr) : Component(id, name, "light"), StatefulCommand(this, f) {}
|
||||
|
||||
void updateState(bool state) {
|
||||
State::updateState(state ? "ON" : "OFF");
|
||||
}
|
||||
|
||||
void buildConfig(JsonDocument& jsonDoc) override {
|
||||
Component::buildConfig(jsonDoc);
|
||||
StatefulCommand::buildConfig(jsonDoc);
|
||||
}
|
||||
};
|
||||
|
||||
struct Number : Component, StatefulCommand {
|
||||
unsigned int min = 1;
|
||||
unsigned int max = 100;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user