sensor fix, readme configuration examples

master
HB 5 years ago
parent b567cbd7a5
commit a37a62e31d

@ -0,0 +1,4 @@
```yaml
# example configuration:
```

@ -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,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
```

@ -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,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)
Loading…
Cancel
Save