This commit is contained in:
Otto Winter 2019-05-24 23:08:04 +02:00
parent 16c2929bb4
commit 12ff280d3b
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
3 changed files with 9 additions and 25 deletions

View File

@ -3,38 +3,26 @@
class CustomSensor : public Component, public Sensor {
public:
void loop() override {
publish_state(42.0);
}
void loop() override { publish_state(42.0); }
};
class CustomTextSensor : public Component, public TextSensor {
public:
void loop() override {
publish_state("Hello World");
}
void loop() override { publish_state("Hello World"); }
};
class CustomBinarySensor : public Component, public BinarySensor {
public:
void loop() override {
publish_state(false);
}
void loop() override { publish_state(false); }
};
class CustomSwitch : public Switch {
protected:
void write_state(bool state) override {
ESP_LOGD("custom_switch", "Setting %s", ONOFF(state));
}
void write_state(bool state) override { ESP_LOGD("custom_switch", "Setting %s", ONOFF(state)); }
};
class CustomComponent : public PollingComponent {
public:
void setup() override {
ESP_LOGD("custom_component", "Setup");
}
void update() override {
ESP_LOGD("custom_component", "Update");
}
void setup() override { ESP_LOGD("custom_component", "Setup"); }
void update() override { ESP_LOGD("custom_component", "Update"); }
};

View File

@ -11,7 +11,7 @@ void setup() {
App.init_ota()->start_safe_mode();
// LEDC is only available on ESP32! for the ESP8266, take a look at App.make_esp8266_pwm_output().
auto *red = App.make_ledc_output(32); // on pin 32
auto *red = App.make_ledc_output(32); // on pin 32
auto *green = App.make_ledc_output(33);
auto *blue = App.make_ledc_output(34);
App.make_rgb_light("Livingroom Light", red, green, blue);
@ -23,6 +23,4 @@ void setup() {
App.setup();
}
void loop() {
App.loop();
}
void loop() { App.loop(); }

View File

@ -29,6 +29,4 @@ void setup() {
App.setup();
}
void loop() {
App.loop();
}
void loop() { App.loop(); }