2019-05-11 15:12:30 +02:00
|
|
|
#pragma once
|
2019-05-10 22:13:26 +02:00
|
|
|
#include "esphome.h"
|
2019-05-08 11:31:06 +02:00
|
|
|
|
|
|
|
class CustomSensor : public Component, public Sensor {
|
|
|
|
public:
|
2019-05-24 23:08:04 +02:00
|
|
|
void loop() override { publish_state(42.0); }
|
2019-05-08 11:31:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class CustomTextSensor : public Component, public TextSensor {
|
|
|
|
public:
|
2019-05-24 23:08:04 +02:00
|
|
|
void loop() override { publish_state("Hello World"); }
|
2019-05-08 11:31:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class CustomBinarySensor : public Component, public BinarySensor {
|
|
|
|
public:
|
2019-05-24 23:08:04 +02:00
|
|
|
void loop() override { publish_state(false); }
|
2019-05-08 11:31:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class CustomSwitch : public Switch {
|
|
|
|
protected:
|
2019-05-24 23:08:04 +02:00
|
|
|
void write_state(bool state) override { ESP_LOGD("custom_switch", "Setting %s", ONOFF(state)); }
|
2019-05-08 11:31:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class CustomComponent : public PollingComponent {
|
|
|
|
public:
|
2019-05-24 23:08:04 +02:00
|
|
|
void setup() override { ESP_LOGD("custom_component", "Setup"); }
|
|
|
|
void update() override { ESP_LOGD("custom_component", "Update"); }
|
2019-05-08 11:31:06 +02:00
|
|
|
};
|
2019-05-27 09:58:55 +02:00
|
|
|
|
|
|
|
class CustomBinaryOutput : public BinaryOutput, public Component {
|
|
|
|
protected:
|
|
|
|
void write_state(bool state) override { ESP_LOGD("custom_output", "Setting %s", ONOFF(state)); }
|
|
|
|
};
|
|
|
|
|
|
|
|
class CustomFloatOutput : public FloatOutput, public Component {
|
|
|
|
protected:
|
|
|
|
void write_state(float state) override { ESP_LOGD("custom_output", "Setting %f", state); }
|
|
|
|
};
|