1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-22 21:22:22 +01:00

Let esphomeyaml know about class inheritance (#229)

* Allow overriding setup priority

* Add inheritance tree

* Global variables

* Tests and better validation

* Fix

* Lint
This commit is contained in:
Otto Winter
2018-11-12 23:30:31 +01:00
committed by GitHub
parent 4f375757a5
commit 15331edb78
128 changed files with 1572 additions and 989 deletions

View File

@@ -1,33 +1,35 @@
import voluptuous as vol
from esphomeyaml.components import sensor
from esphomeyaml.components.time import sntp
from esphomeyaml.components import sensor, time
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_TIME_ID
from esphomeyaml.helpers import App, Application, get_variable, variable
from esphomeyaml.helpers import App, Application, Component, get_variable, setup_component, variable
DEPENDENCIES = ['time']
CONF_POWER_ID = 'power_id'
MakeTotalDailyEnergySensor = Application.MakeTotalDailyEnergySensor
TotalDailyEnergy = sensor.sensor_ns.TotalDailyEnergy
MakeTotalDailyEnergySensor = Application.struct('MakeTotalDailyEnergySensor')
TotalDailyEnergy = sensor.sensor_ns.class_('TotalDailyEnergy', sensor.Sensor, Component)
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(TotalDailyEnergy),
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTotalDailyEnergySensor),
cv.GenerateID(CONF_TIME_ID): cv.use_variable_id(sntp.SNTPComponent),
vol.Required(CONF_POWER_ID): cv.use_variable_id(None),
}))
cv.GenerateID(CONF_TIME_ID): cv.use_variable_id(time.RealTimeClockComponent),
vol.Required(CONF_POWER_ID): cv.use_variable_id(sensor.Sensor),
}).extend(cv.COMPONENT_SCHEMA.schema))
def to_code(config):
for time in get_variable(config[CONF_TIME_ID]):
for time_ in get_variable(config[CONF_TIME_ID]):
yield
for sens in get_variable(config[CONF_POWER_ID]):
yield
rhs = App.make_total_daily_energy_sensor(config[CONF_NAME], time, sens)
rhs = App.make_total_daily_energy_sensor(config[CONF_NAME], time_, sens)
make = variable(config[CONF_MAKE_ID], rhs)
sensor.setup_sensor(make.Ptotal_energy, make.Pmqtt, config)
total_energy = make.Ptotal_energy
sensor.setup_sensor(total_energy, make.Pmqtt, config)
setup_component(total_energy, config)
BUILD_FLAGS = '-DUSE_TOTAL_DAILY_ENERGY_SENSOR'