Compare commits
10
Commits
09a49f75d9
...
9ee2ee5864
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ee2ee5864 | ||
|
|
31c3e4aba9 | ||
|
|
8a9291c8ac | ||
|
|
b3f368ad3a | ||
|
|
a37a62e31d | ||
|
|
b567cbd7a5 | ||
|
|
11791476b0 | ||
|
|
ae336d2b80 | ||
|
|
c5a762956f | ||
|
|
a9eab678d0 |
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
output:
|
||||
- platform: empty_binary_output
|
||||
id: empty_binary_output_1
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
binary_sensor:
|
||||
- platform: empty_binary_sensor
|
||||
name: Empty binary sensor
|
||||
```
|
||||
@@ -0,0 +1,6 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_component:
|
||||
id: empty_component_1
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_compound_sensor
|
||||
sensor1:
|
||||
name: Sensor 1
|
||||
sensor2:
|
||||
name: Sensor 2
|
||||
sensor3:
|
||||
name: Sensor 3
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
cover:
|
||||
platform: empty_cover
|
||||
name: Empty cover
|
||||
```
|
||||
@@ -0,0 +1,13 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
fan:
|
||||
- platform: empty_fan
|
||||
name: Empty fan
|
||||
output: gpio_d1
|
||||
|
||||
output:
|
||||
- platform: gpio
|
||||
pin: D1
|
||||
id: gpio_d1
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
output:
|
||||
- platform: empty_float_output
|
||||
id: empty_float_output_1
|
||||
```
|
||||
@@ -0,0 +1,11 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_i2c_component:
|
||||
id: empty_i2c_component_1
|
||||
address: 0x01 # optional
|
||||
|
||||
i2c:
|
||||
sda: 4
|
||||
scl: 5
|
||||
```
|
||||
@@ -7,11 +7,14 @@ namespace empty_i2c_component {
|
||||
static const char *TAG = "empty_i2c_component.component";
|
||||
|
||||
void EmptyI2CComponent::setup() {
|
||||
|
||||
this->write_register(0x0, 0x1, 0x1);
|
||||
}
|
||||
|
||||
void EmptyI2CComponent::loop() {
|
||||
|
||||
this->write_register(0x0, 0x1, 0x1);
|
||||
delay(1000);
|
||||
this->write_register(0x0, 0x0, 0x1);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void EmptyI2CComponent::dump_config(){
|
||||
@@ -20,4 +23,4 @@ void EmptyI2CComponent::dump_config(){
|
||||
|
||||
|
||||
} // namespace empty_i2c_component
|
||||
} // namespace esphome
|
||||
} // namespace esphome
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_i2c_sensor
|
||||
name: Empty I2C sensor
|
||||
|
||||
i2c:
|
||||
sda: 4
|
||||
scl: 5
|
||||
```
|
||||
@@ -0,0 +1,14 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
light:
|
||||
- platform: empty_light
|
||||
name: Empty light
|
||||
output: pwm_output
|
||||
|
||||
output:
|
||||
- platform: esp8266_pwm
|
||||
pin: D1
|
||||
frequency: 1000 Hz
|
||||
id: pwm_output
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_sensor
|
||||
name: Empty sensor
|
||||
```
|
||||
@@ -1,17 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.const import CONF_ID, UNIT_EMPTY, ICON_EMPTY
|
||||
|
||||
empty_sensor_ns = cg.esphome_ns.namespace('empty_sensor')
|
||||
|
||||
EmptySensor = empty_sensor_ns.class_('EmptySensor', cg.PollingComponent)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||
cv.GenerateID(): cv.declare_id(EmptySensor)
|
||||
}).extend(cv.polling_component_schema('60s'))
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield sensor.register_sensor(var, config)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_sensor_hub:
|
||||
id: empty_sensor_hub_1
|
||||
|
||||
sensor:
|
||||
- platform: empty_sensor_hub
|
||||
name: Sensor for empty sensor hub 1
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Sensor for empty sensor hub 2
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
text_sensor:
|
||||
- platform: empty_sensor_hub
|
||||
name: Text sensor for empty sensor hub 1
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Text sensor for empty sensor hub 2
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
binary_sensor:
|
||||
- platform: empty_sensor_hub
|
||||
name: Binary sensor for empty sensor hub 1
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Binary sensor for empty sensor hub 2
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
```
|
||||
@@ -0,0 +1,20 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
AUTO_LOAD = ['sensor','text_sensor', 'binary_sensor']
|
||||
MULTI_CONF = True
|
||||
|
||||
CONF_HUB_ID = 'empty_sensor_hub_id'
|
||||
|
||||
empty_sensor_hub_ns = cg.esphome_ns.namespace('empty_sensor_hub')
|
||||
|
||||
EmptySensorHub = empty_sensor_hub_ns.class_('EmptySensorHub', cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(EmptySensorHub),
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
@@ -0,0 +1,23 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
from esphome.const import CONF_ID
|
||||
from . import EmptySensorHub, CONF_HUB_ID
|
||||
|
||||
DEPENDENCIES = ['empty_sensor_hub']
|
||||
|
||||
binary_sensor_ns = cg.esphome_ns.namespace('binary_sensor')
|
||||
BinarySensor = binary_sensor_ns.class_('BinarySensor', binary_sensor.BinarySensor, cg.Nameable)
|
||||
|
||||
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(BinarySensor),
|
||||
cv.GenerateID(CONF_HUB_ID): cv.use_id(EmptySensorHub)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
paren = yield cg.get_variable(config[CONF_HUB_ID])
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
|
||||
yield binary_sensor.register_binary_sensor(var, config)
|
||||
|
||||
cg.add(paren.register_binary_sensor(var))
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "empty_sensor_hub.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_sensor_hub {
|
||||
|
||||
static const char *TAG = "empty_sensor_hub.component";
|
||||
|
||||
void EmptySensorHub::setup(){
|
||||
|
||||
}
|
||||
|
||||
void EmptySensorHub::dump_config(){
|
||||
for (auto *sensor : this->sensors_) {
|
||||
LOG_SENSOR(" ", "Sensor", sensor);
|
||||
}
|
||||
|
||||
for(auto *text_sensor : this->text_sensors_){
|
||||
LOG_TEXT_SENSOR(" ", "Text sensor", text_sensor);
|
||||
}
|
||||
|
||||
for(auto *binary_sensor : this->binary_sensors_){
|
||||
LOG_BINARY_SENSOR(" ", "Binary sensor", binary_sensor);
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace empty_sensor_hub
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_sensor_hub {
|
||||
|
||||
class EmptySensorHub : public Component {
|
||||
public:
|
||||
void register_sensor(sensor::Sensor *obj) { this->sensors_.push_back(obj); }
|
||||
void register_text_sensor(text_sensor::TextSensor *obj) { this->text_sensors_.push_back(obj); }
|
||||
void register_binary_sensor(binary_sensor::BinarySensor *obj) { this->binary_sensors_.push_back(obj); }
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
std::vector<sensor::Sensor *> sensors_;
|
||||
std::vector<text_sensor::TextSensor *> text_sensors_;
|
||||
std::vector<binary_sensor::BinarySensor *> binary_sensors_;
|
||||
};
|
||||
|
||||
} //namespace empty_sensor_hub
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,23 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from esphome.const import CONF_ID, UNIT_EMPTY, ICON_EMPTY
|
||||
from . import EmptySensorHub, CONF_HUB_ID
|
||||
|
||||
DEPENDENCIES = ['empty_sensor_hub']
|
||||
|
||||
sensor_ns = cg.esphome_ns.namespace('sensor')
|
||||
Sensor = sensor_ns.class_('Sensor', sensor.Sensor, cg.Nameable)
|
||||
|
||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||
cv.GenerateID(): cv.declare_id(Sensor),
|
||||
cv.GenerateID(CONF_HUB_ID): cv.use_id(EmptySensorHub)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
paren = yield cg.get_variable(config[CONF_HUB_ID])
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
|
||||
yield sensor.register_sensor(var, config)
|
||||
|
||||
cg.add(paren.register_sensor(var))
|
||||
@@ -0,0 +1,23 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import text_sensor
|
||||
from esphome.const import CONF_ID
|
||||
from . import EmptySensorHub, CONF_HUB_ID
|
||||
|
||||
DEPENDENCIES = ['empty_sensor_hub']
|
||||
|
||||
text_sensor_ns = cg.esphome_ns.namespace('text_sensor')
|
||||
TextSensor = text_sensor_ns.class_('TextSensor', text_sensor.TextSensor, cg.Nameable)
|
||||
|
||||
CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(TextSensor),
|
||||
cv.GenerateID(CONF_HUB_ID): cv.use_id(EmptySensorHub)
|
||||
}).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
def to_code(config):
|
||||
paren = yield cg.get_variable(config[CONF_HUB_ID])
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
|
||||
yield text_sensor.register_text_sensor(var, config)
|
||||
|
||||
cg.add(paren.register_text_sensor(var))
|
||||
@@ -0,0 +1,11 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_spi_component:
|
||||
id: empty_spi_component_1
|
||||
cs_pin: D8
|
||||
|
||||
spi:
|
||||
clk_pin: D5
|
||||
miso_pin: D6
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_spi_sensor
|
||||
name: Empty SPI sensor
|
||||
cs_pin: D8
|
||||
|
||||
spi:
|
||||
clk_pin: D5
|
||||
miso_pin: D6
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
switch:
|
||||
- platform: empty_switch
|
||||
name: Empty switch
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
text_sensor:
|
||||
- platform: empty_text_sensor
|
||||
name: Empty text sensor
|
||||
```
|
||||
@@ -0,0 +1,11 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
empty_uart_component:
|
||||
id: empty_uart_component_1
|
||||
|
||||
uart:
|
||||
tx_pin: D0
|
||||
rx_pin: D1
|
||||
baud_rate: 9600
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
```yaml
|
||||
# example configuration:
|
||||
|
||||
sensor:
|
||||
- platform: empty_uart_sensor
|
||||
name: Empty UART sensor
|
||||
|
||||
uart:
|
||||
tx_pin: D0
|
||||
rx_pin: D1
|
||||
baud_rate: 9600
|
||||
```
|
||||
@@ -1,24 +0,0 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "example_custom_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace example_custom_sensor {
|
||||
|
||||
void ExampleCustomSensor::setup() {
|
||||
// This will be called by App.setup()
|
||||
}
|
||||
|
||||
void ExampleCustomSensor::loop() {
|
||||
// This will be called by App.loop()
|
||||
}
|
||||
|
||||
void ExampleCustomSensor::update(){
|
||||
// This will be called every "update_interval" milliseconds.
|
||||
}
|
||||
|
||||
void ExampleCustomSensor::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty custom sensor");
|
||||
}
|
||||
|
||||
} //namespace example_custom_sensor
|
||||
} //namespace esphome
|
||||
@@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace example_custom_sensor {
|
||||
|
||||
class ExampleCustomSensor : public sensor::Sensor, public PollingComponent {
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void loop() override;
|
||||
void update() override;
|
||||
};
|
||||
|
||||
} //namespace example_custom_sensor
|
||||
} //namespace esphome
|
||||
@@ -1,17 +0,0 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
example_custom_sensor_ns = cg.esphome_ns.namespace('example_custom_sensor')
|
||||
|
||||
ExampleCustomSensor = example_custom_sensor_ns.class_('ExampleCustomSensor', cg.PollingComponent)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(ExampleCustomSensor)
|
||||
}).extend(cv.polling_component_schema('60s'))
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.4 KiB |
+31
-16
@@ -6,31 +6,38 @@ packages:
|
||||
|
||||
sensor:
|
||||
- platform: empty_sensor
|
||||
id: empty_sensor_1
|
||||
name: Empty sensor
|
||||
|
||||
- platform: empty_i2c_sensor
|
||||
id: empty_i2c_sensor_1
|
||||
name: Empty I2C sensor
|
||||
|
||||
- platform: empty_spi_sensor
|
||||
id: empty_spi_sensor_1
|
||||
name: Empty SPI sensor
|
||||
cs_pin: D8
|
||||
|
||||
- platform: empty_uart_sensor
|
||||
id: empty_uart_sensor_1
|
||||
name: Empty UART sensor
|
||||
|
||||
- platform: empty_compound_sensor
|
||||
id: empty_compound_sensor_1
|
||||
sensor1:
|
||||
name: "Sensor 1"
|
||||
name: Sensor 1
|
||||
sensor2:
|
||||
name: "Sensor 2"
|
||||
name: Sensor 2
|
||||
sensor3:
|
||||
name: "Sensor 3"
|
||||
name: Sensor 3
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Sensor for empty sensor hub
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
binary_sensor:
|
||||
- platform: empty_binary_sensor
|
||||
id: empty_binary_sensor_1
|
||||
name: Empty binary sensor
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Binary sensor for empty sensor hub
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
output:
|
||||
- platform: empty_binary_output
|
||||
id: empty_binary_output_1
|
||||
@@ -40,25 +47,29 @@ output:
|
||||
|
||||
light:
|
||||
- platform: empty_light
|
||||
id: empty_light_1
|
||||
name: Empty light
|
||||
output: empty_float_output_1
|
||||
|
||||
switch:
|
||||
- platform: empty_switch
|
||||
id: empty_switch_1
|
||||
name: Empty switch
|
||||
|
||||
fan:
|
||||
- platform: empty_fan
|
||||
id: empty_fan_1
|
||||
name: Empty fan
|
||||
output: empty_binary_output_1
|
||||
|
||||
text_sensor:
|
||||
- platform: empty_text_sensor
|
||||
id: empty_text_sensor_1
|
||||
|
||||
name: Empty text sensor
|
||||
|
||||
- platform: empty_sensor_hub
|
||||
name: Text sensor for empty sensor hub
|
||||
empty_sensor_hub_id: empty_sensor_hub_1
|
||||
|
||||
cover:
|
||||
platform: empty_cover
|
||||
id: empty_cover_1
|
||||
name: Empty cover
|
||||
|
||||
empty_component:
|
||||
id: empty_component_1
|
||||
@@ -85,4 +96,8 @@ spi:
|
||||
|
||||
empty_spi_component:
|
||||
id: empty_spi_component_1
|
||||
cs_pin: D8
|
||||
cs_pin: D8
|
||||
|
||||
empty_sensor_hub:
|
||||
id: empty_sensor_hub_1
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
packages:
|
||||
device: !include device.yaml
|
||||
|
||||
sensor:
|
||||
- platform: example_custom_sensor
|
||||
id: example_custom_sensor_1
|
||||
Reference in New Issue
Block a user