master
HB 5 years ago
parent 1e4202b18c
commit ae2bff7380

@ -0,0 +1,18 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import i2c, sensor
from esphome.const import CONF_ID
DEPENDENCIES = ['i2c']
empty_i2c_component_ns = cg.esphome_ns.namespace('empty_i2c_component')
EmptyI2CComponent = empty_i2c_component_ns.class_('EmptyI2CComponent', cg.Component, i2c.I2CDevice)
CONFIG_SCHEMA = cv.Schema({
cv.GenerateID(): cv.declare_id(EmptyI2CComponent)
}).extend(cv.COMPONENT_SCHEMA).extend(i2c.i2c_device_schema(0x29))
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield i2c.register_i2c_device(var, config)

@ -0,0 +1,23 @@
#include "esphome/core/log.h"
#include "empty_i2c_component.h"
namespace esphome {
namespace empty_i2c_component {
static const char *TAG = "empty_i2c_component.component";
void EmptyI2CComponent::setup() {
}
void EmptyI2CComponent::loop() {
}
void EmptyI2CComponent::dump_config(){
ESP_LOGCONFIG(TAG, "Empty i2c component");
}
} // namespace empty_i2c_component
} // namespace esphome

@ -0,0 +1,18 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome {
namespace empty_i2c_component {
class EmptyI2CComponent : public i2c::I2CDevice, public Component {
public:
void setup() override;
void loop() override;
void dump_config() override;
};
} // namespace empty_i2c_component
} // namespace esphome

@ -0,0 +1,18 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import uart
from esphome.const import CONF_ID
DEPENDENCIES = ['uart']
empty_uart_component_ns = cg.esphome_ns.namespace('empty_uart_component')
EmptyUARTComponent = empty_uart_component_ns.class_('EmptyUARTComponent', cg.Component, uart.UARTDevice)
CONFIG_SCHEMA = cv.Schema({
cv.GenerateID(): cv.declare_id(EmptyUARTComponent)
}).extend(cv.COMPONENT_SCHEMA).extend(uart.UART_DEVICE_SCHEMA)
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield uart.register_uart_device(var, config)

@ -0,0 +1,22 @@
#include "esphome/core/log.h"
#include "empty_uart_component.h"
namespace esphome {
namespace empty_uart_component {
static const char *TAG = "empty_uart_component.component";
void EmptyUARTComponent::setup() {
}
void EmptyUARTComponent::loop() {
}
void EmptyUARTComponent::dump_config(){
ESP_LOGCONFIG(TAG, "Empty i2c component");
}
} // namespace empty_uart_component
} // namespace esphome

@ -0,0 +1,18 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/uart/uart.h"
namespace esphome {
namespace empty_uart_component {
class EmptyUARTComponent : public uart::UARTDevice, public Component {
public:
void setup() override;
void loop() override;
void dump_config() override;
};
} // namespace empty_uart_component
} // namespace esphome

@ -39,4 +39,20 @@ cover:
id: empty_cover_1 id: empty_cover_1
empty_component: empty_component:
id: empty_component_1 id: empty_component_1
i2c:
sda: 4
scl: 5
empty_i2c_component:
id: empty_i2c_component_1
address: 0x01
uart:
tx_pin: D0
rx_pin: D1
baud_rate: 9600
empty_uart_component:
id: empty_uart_component_1
Loading…
Cancel
Save