From a37a62e31db4de0926713b1e3a5b1956661a56da Mon Sep 17 00:00:00 2001 From: HB Date: Wed, 30 Sep 2020 23:58:10 +0200 Subject: [PATCH] sensor fix, readme configuration examples --- custom_components/README.md | 4 ++++ .../empty_binary_output/README.md | 7 ++++++ .../empty_binary_sensor/README.md | 7 ++++++ .../empty_compound_sensor/README.md | 12 ++++++++++ custom_components/empty_cover/README.md | 7 ++++++ custom_components/empty_fan/README.md | 13 ++++++++++ .../empty_float_output/README.md | 7 ++++++ .../empty_i2c_component/README.md | 11 +++++++++ custom_components/empty_i2c_sensor/README.md | 11 +++++++++ custom_components/empty_light/README.md | 14 +++++++++++ custom_components/empty_sensor/README.md | 7 ++++++ custom_components/empty_sensor/sensor.py | 5 ++-- .../empty_spi_component/README.md | 11 +++++++++ custom_components/empty_spi_sensor/README.md | 12 ++++++++++ custom_components/empty_switch/README.md | 7 ++++++ custom_components/empty_text_sensor/README.md | 7 ++++++ .../empty_uart_component/README.md | 11 +++++++++ custom_components/empty_uart_sensor/README.md | 12 ++++++++++ .../example_custom_sensor.cpp | 24 ------------------- .../example_custom_sensor.h | 17 ------------- .../example_custom_sensor/sensor.py | 17 ------------- 21 files changed, 163 insertions(+), 60 deletions(-) create mode 100644 custom_components/README.md create mode 100644 custom_components/empty_binary_output/README.md create mode 100644 custom_components/empty_binary_sensor/README.md create mode 100644 custom_components/empty_compound_sensor/README.md create mode 100644 custom_components/empty_cover/README.md create mode 100644 custom_components/empty_fan/README.md create mode 100644 custom_components/empty_float_output/README.md create mode 100644 custom_components/empty_i2c_component/README.md create mode 100644 custom_components/empty_i2c_sensor/README.md create mode 100644 custom_components/empty_light/README.md create mode 100644 custom_components/empty_sensor/README.md create mode 100644 custom_components/empty_spi_component/README.md create mode 100644 custom_components/empty_spi_sensor/README.md create mode 100644 custom_components/empty_switch/README.md create mode 100644 custom_components/empty_text_sensor/README.md create mode 100644 custom_components/empty_uart_component/README.md create mode 100644 custom_components/empty_uart_sensor/README.md delete mode 100644 custom_components/example_custom_sensor/example_custom_sensor.cpp delete mode 100644 custom_components/example_custom_sensor/example_custom_sensor.h delete mode 100644 custom_components/example_custom_sensor/sensor.py diff --git a/custom_components/README.md b/custom_components/README.md new file mode 100644 index 0000000..a320e42 --- /dev/null +++ b/custom_components/README.md @@ -0,0 +1,4 @@ +```yaml +# example configuration: + +``` \ No newline at end of file diff --git a/custom_components/empty_binary_output/README.md b/custom_components/empty_binary_output/README.md new file mode 100644 index 0000000..46b168f --- /dev/null +++ b/custom_components/empty_binary_output/README.md @@ -0,0 +1,7 @@ +```yaml +# example configuration: + +output: + - platform: empty_binary_output + id: empty_binary_output_1 +``` \ No newline at end of file diff --git a/custom_components/empty_binary_sensor/README.md b/custom_components/empty_binary_sensor/README.md new file mode 100644 index 0000000..aea5697 --- /dev/null +++ b/custom_components/empty_binary_sensor/README.md @@ -0,0 +1,7 @@ +```yaml +# example configuration: + +binary_sensor: + - platform: empty_binary_sensor + name: Empty binary sensor +``` \ No newline at end of file diff --git a/custom_components/empty_compound_sensor/README.md b/custom_components/empty_compound_sensor/README.md new file mode 100644 index 0000000..055aa78 --- /dev/null +++ b/custom_components/empty_compound_sensor/README.md @@ -0,0 +1,12 @@ +```yaml +# example configuration: + +sensor: + - platform: empty_compound_sensor + sensor1: + name: Sensor 1 + sensor2: + name: Sensor 2 + sensor3: + name: Sensor 3 +``` \ No newline at end of file diff --git a/custom_components/empty_cover/README.md b/custom_components/empty_cover/README.md new file mode 100644 index 0000000..3b186ac --- /dev/null +++ b/custom_components/empty_cover/README.md @@ -0,0 +1,7 @@ +```yaml +# example configuration: + +cover: + platform: empty_cover + name: Empty cover +``` \ No newline at end of file diff --git a/custom_components/empty_fan/README.md b/custom_components/empty_fan/README.md new file mode 100644 index 0000000..cff0a25 --- /dev/null +++ b/custom_components/empty_fan/README.md @@ -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 +``` \ No newline at end of file diff --git a/custom_components/empty_float_output/README.md b/custom_components/empty_float_output/README.md new file mode 100644 index 0000000..ec6fb3d --- /dev/null +++ b/custom_components/empty_float_output/README.md @@ -0,0 +1,7 @@ +```yaml +# example configuration: + +output: + - platform: empty_float_output + id: empty_float_output_1 +``` \ No newline at end of file diff --git a/custom_components/empty_i2c_component/README.md b/custom_components/empty_i2c_component/README.md new file mode 100644 index 0000000..b6a5d1c --- /dev/null +++ b/custom_components/empty_i2c_component/README.md @@ -0,0 +1,11 @@ +```yaml +# example configuration: + +empty_i2c_component: + id: empty_i2c_component_1 + address: 0x01 # optional + +i2c: + sda: 4 + scl: 5 +``` \ No newline at end of file diff --git a/custom_components/empty_i2c_sensor/README.md b/custom_components/empty_i2c_sensor/README.md new file mode 100644 index 0000000..03e93f4 --- /dev/null +++ b/custom_components/empty_i2c_sensor/README.md @@ -0,0 +1,11 @@ +```yaml +# example configuration: + +sensor: + - platform: empty_i2c_sensor + name: Empty I2C sensor + +i2c: + sda: 4 + scl: 5 +``` \ No newline at end of file diff --git a/custom_components/empty_light/README.md b/custom_components/empty_light/README.md new file mode 100644 index 0000000..02939fd --- /dev/null +++ b/custom_components/empty_light/README.md @@ -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 +``` \ No newline at end of file diff --git a/custom_components/empty_sensor/README.md b/custom_components/empty_sensor/README.md new file mode 100644 index 0000000..8955484 --- /dev/null +++ b/custom_components/empty_sensor/README.md @@ -0,0 +1,7 @@ +```yaml +# example configuration: + +sensor: + - platform: empty_sensor + name: Empty sensor +``` \ No newline at end of file diff --git a/custom_components/empty_sensor/sensor.py b/custom_components/empty_sensor/sensor.py index fcee0e4..49ae849 100644 --- a/custom_components/empty_sensor/sensor.py +++ b/custom_components/empty_sensor/sensor.py @@ -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) \ No newline at end of file diff --git a/custom_components/empty_spi_component/README.md b/custom_components/empty_spi_component/README.md new file mode 100644 index 0000000..7757be3 --- /dev/null +++ b/custom_components/empty_spi_component/README.md @@ -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 +``` \ No newline at end of file diff --git a/custom_components/empty_spi_sensor/README.md b/custom_components/empty_spi_sensor/README.md new file mode 100644 index 0000000..cac0b4a --- /dev/null +++ b/custom_components/empty_spi_sensor/README.md @@ -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 +``` \ No newline at end of file diff --git a/custom_components/empty_switch/README.md b/custom_components/empty_switch/README.md new file mode 100644 index 0000000..1c9fddb --- /dev/null +++ b/custom_components/empty_switch/README.md @@ -0,0 +1,7 @@ +```yaml +# example configuration: + +switch: + - platform: empty_switch + name: Empty switch +``` \ No newline at end of file diff --git a/custom_components/empty_text_sensor/README.md b/custom_components/empty_text_sensor/README.md new file mode 100644 index 0000000..0eb5922 --- /dev/null +++ b/custom_components/empty_text_sensor/README.md @@ -0,0 +1,7 @@ +```yaml +# example configuration: + +text_sensor: + - platform: empty_text_sensor + name: Empty text sensor +``` \ No newline at end of file diff --git a/custom_components/empty_uart_component/README.md b/custom_components/empty_uart_component/README.md new file mode 100644 index 0000000..8ca5fa3 --- /dev/null +++ b/custom_components/empty_uart_component/README.md @@ -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 +``` \ No newline at end of file diff --git a/custom_components/empty_uart_sensor/README.md b/custom_components/empty_uart_sensor/README.md new file mode 100644 index 0000000..754b876 --- /dev/null +++ b/custom_components/empty_uart_sensor/README.md @@ -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 +``` \ No newline at end of file diff --git a/custom_components/example_custom_sensor/example_custom_sensor.cpp b/custom_components/example_custom_sensor/example_custom_sensor.cpp deleted file mode 100644 index 4cab1ea..0000000 --- a/custom_components/example_custom_sensor/example_custom_sensor.cpp +++ /dev/null @@ -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 \ No newline at end of file diff --git a/custom_components/example_custom_sensor/example_custom_sensor.h b/custom_components/example_custom_sensor/example_custom_sensor.h deleted file mode 100644 index 78795b9..0000000 --- a/custom_components/example_custom_sensor/example_custom_sensor.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/custom_components/example_custom_sensor/sensor.py b/custom_components/example_custom_sensor/sensor.py deleted file mode 100644 index 0c9f0b2..0000000 --- a/custom_components/example_custom_sensor/sensor.py +++ /dev/null @@ -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) - \ No newline at end of file