mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
CSE7766 update interval (#250)
* CSE7766 update interval * PollingComponent
This commit is contained in:
parent
5d5529ff15
commit
e37e986276
1 changed files with 5 additions and 4 deletions
|
@ -4,12 +4,12 @@ from esphomeyaml.components import sensor, uart
|
|||
from esphomeyaml.components.uart import UARTComponent
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_CURRENT, CONF_ID, CONF_NAME, CONF_POWER, CONF_UART_ID, \
|
||||
CONF_VOLTAGE
|
||||
from esphomeyaml.helpers import App, Pvariable, get_variable, setup_component, Component
|
||||
CONF_UPDATE_INTERVAL, CONF_VOLTAGE
|
||||
from esphomeyaml.helpers import App, PollingComponent, Pvariable, get_variable, setup_component
|
||||
|
||||
DEPENDENCIES = ['uart']
|
||||
|
||||
CSE7766Component = sensor.sensor_ns.class_('CSE7766Component', Component, uart.UARTDevice)
|
||||
CSE7766Component = sensor.sensor_ns.class_('CSE7766Component', PollingComponent, uart.UARTDevice)
|
||||
CSE7766VoltageSensor = sensor.sensor_ns.class_('CSE7766VoltageSensor',
|
||||
sensor.EmptySensor)
|
||||
CSE7766CurrentSensor = sensor.sensor_ns.class_('CSE7766CurrentSensor',
|
||||
|
@ -30,6 +30,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
|
|||
vol.Optional(CONF_POWER): cv.nameable(sensor.SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(CSE7766PowerSensor),
|
||||
})),
|
||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema), cv.has_at_least_one_key(CONF_VOLTAGE, CONF_CURRENT,
|
||||
CONF_POWER))
|
||||
|
||||
|
@ -38,7 +39,7 @@ def to_code(config):
|
|||
for uart_ in get_variable(config[CONF_UART_ID]):
|
||||
yield
|
||||
|
||||
rhs = App.make_cse7766(uart_)
|
||||
rhs = App.make_cse7766(uart_, config.get(CONF_UPDATE_INTERVAL))
|
||||
cse = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_VOLTAGE in config:
|
||||
|
|
Loading…
Reference in a new issue