Progress
This commit is contained in:
parent
e04fd29b1d
commit
1d31a8b63f
21
README.md
Normal file
21
README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# A component that reads CSV values from the uart.
|
||||
|
||||
A configured uart is required.
|
||||
|
||||
Configure a list of sensors. The index is required, the rest is the standard sensor config.
|
||||
|
||||
Example:
|
||||
```yaml
|
||||
sensor:
|
||||
- platform: serial_csv
|
||||
uart_id: my_uart # optional
|
||||
sensors:
|
||||
- index: 0
|
||||
name: First value
|
||||
- index: 3
|
||||
name: Fourth value
|
||||
```
|
||||
|
||||
|
||||
https://github.com/ssieb/esphome_components/tree/master/components/serial_csv
|
||||
https://github.com/esphome/esphome/blob/dev/esphome/components/dht/sensor.py#L34
|
19
sensor.py
19
sensor.py
@ -3,25 +3,26 @@ import esphome.config_validation as cv
|
||||
from esphome import automation
|
||||
from esphome.components import uart
|
||||
from esphome.components import sensor
|
||||
from esphome.const import CONF_ID, CONF_INDEX, CONF_SENSORS
|
||||
from esphome.const import CONF_ID, CONF_INDEX, CONF_SENSORS, CONF_HUMIDITY, CONF_MODEL, CONF_PIN, CONF_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, DEVICE_CLASS_TEMPERATURE
|
||||
|
||||
CODEOWNERS = ["@ssieb"]
|
||||
CODEOWNERS = ["@jonatanrek"]
|
||||
|
||||
DEPENDENCIES = ['uart']
|
||||
|
||||
serial_ns = cg.esphome_ns.namespace('serial')
|
||||
|
||||
SerialCSV = serial_ns.class_('SerialCSV', cg.Component, sensor.Sensor, uart.UARTDevice)
|
||||
Marlin2 = serial_ns.class_('Marlin2', cg.Component, sensor.Sensor, uart.UARTDevice)
|
||||
|
||||
CONFIG_SCHEMA = uart.UART_DEVICE_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(SerialCSV),
|
||||
cv.GenerateID(): cv.declare_id(Marlin2),
|
||||
cv.Required(CONF_SENSORS): cv.ensure_list(
|
||||
sensor.SENSOR_SCHEMA.extend(
|
||||
{
|
||||
cv.Required(CONF_INDEX): cv.positive_int,
|
||||
}
|
||||
)
|
||||
cv.Optional("bed_current"): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
),
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user