mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +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
|
from esphomeyaml.components.uart import UARTComponent
|
||||||
import esphomeyaml.config_validation as cv
|
import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_CURRENT, CONF_ID, CONF_NAME, CONF_POWER, CONF_UART_ID, \
|
from esphomeyaml.const import CONF_CURRENT, CONF_ID, CONF_NAME, CONF_POWER, CONF_UART_ID, \
|
||||||
CONF_VOLTAGE
|
CONF_UPDATE_INTERVAL, CONF_VOLTAGE
|
||||||
from esphomeyaml.helpers import App, Pvariable, get_variable, setup_component, Component
|
from esphomeyaml.helpers import App, PollingComponent, Pvariable, get_variable, setup_component
|
||||||
|
|
||||||
DEPENDENCIES = ['uart']
|
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',
|
CSE7766VoltageSensor = sensor.sensor_ns.class_('CSE7766VoltageSensor',
|
||||||
sensor.EmptySensor)
|
sensor.EmptySensor)
|
||||||
CSE7766CurrentSensor = sensor.sensor_ns.class_('CSE7766CurrentSensor',
|
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({
|
vol.Optional(CONF_POWER): cv.nameable(sensor.SENSOR_SCHEMA.extend({
|
||||||
cv.GenerateID(): cv.declare_variable_id(CSE7766PowerSensor),
|
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,
|
}).extend(cv.COMPONENT_SCHEMA.schema), cv.has_at_least_one_key(CONF_VOLTAGE, CONF_CURRENT,
|
||||||
CONF_POWER))
|
CONF_POWER))
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ def to_code(config):
|
||||||
for uart_ in get_variable(config[CONF_UART_ID]):
|
for uart_ in get_variable(config[CONF_UART_ID]):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
rhs = App.make_cse7766(uart_)
|
rhs = App.make_cse7766(uart_, config.get(CONF_UPDATE_INTERVAL))
|
||||||
cse = Pvariable(config[CONF_ID], rhs)
|
cse = Pvariable(config[CONF_ID], rhs)
|
||||||
|
|
||||||
if CONF_VOLTAGE in config:
|
if CONF_VOLTAGE in config:
|
||||||
|
|
Loading…
Reference in a new issue