1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-13 22:28:14 +00:00

Remove climate changes

This commit is contained in:
Otto Winter 2019-04-08 18:02:50 +02:00
parent 5497033356
commit 443f4ee209
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
3 changed files with 0 additions and 195 deletions

View File

@ -1,115 +0,0 @@
import voluptuous as vol
from esphome import core
from esphome.automation import ACTION_REGISTRY
from esphome.components import mqtt
from esphome.components.mqtt import setup_mqtt_component
import esphome.config_validation as cv
from esphome.const import CONF_AWAY, CONF_ID, CONF_INTERNAL, CONF_MAX_TEMPERATURE, \
CONF_MIN_TEMPERATURE, CONF_MODE, CONF_MQTT_ID, CONF_TARGET_TEMPERATURE, \
CONF_TARGET_TEMPERATURE_HIGH, CONF_TARGET_TEMPERATURE_LOW, CONF_TEMPERATURE_STEP, CONF_VISUAL
from esphome.core import CORE
from esphome.cpp_generator import Pvariable, add, get_variable, templatable
from esphome.cpp_types import Action, App, Nameable, bool_, esphome_ns, float_
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
})
climate_ns = esphome_ns.namespace('climate')
ClimateDevice = climate_ns.class_('ClimateDevice', Nameable)
ClimateCall = climate_ns.class_('ClimateCall')
ClimateTraits = climate_ns.class_('ClimateTraits')
MQTTClimateComponent = climate_ns.class_('MQTTClimateComponent', mqtt.MQTTComponent)
ClimateMode = climate_ns.enum('ClimateMode')
CLIMATE_MODES = {
'OFF': ClimateMode.CLIMATE_MODE_OFF,
'AUTO': ClimateMode.CLIMATE_MODE_AUTO,
'COOL': ClimateMode.CLIMATE_MODE_COOL,
'HEAT': ClimateMode.CLIMATE_MODE_HEAT,
}
validate_climate_mode = cv.one_of(*CLIMATE_MODES, upper=True)
# Actions
ControlAction = climate_ns.class_('ControlAction', Action)
CLIMATE_SCHEMA = cv.MQTT_COMMAND_COMPONENT_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(ClimateDevice),
cv.GenerateID(CONF_MQTT_ID): cv.declare_variable_id(MQTTClimateComponent),
vol.Optional(CONF_VISUAL, default={}): cv.Schema({
vol.Optional(CONF_MIN_TEMPERATURE): cv.temperature,
vol.Optional(CONF_MAX_TEMPERATURE): cv.temperature,
vol.Optional(CONF_TEMPERATURE_STEP): cv.temperature,
})
})
CLIMATE_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(CLIMATE_SCHEMA.schema)
def setup_climate_core_(climate_var, config):
if CONF_INTERNAL in config:
add(climate_var.set_internal(config[CONF_INTERNAL]))
visual = config[CONF_VISUAL]
if CONF_MIN_TEMPERATURE in visual:
add(climate_var.set_visual_min_temperature_override(visual[CONF_MIN_TEMPERATURE]))
if CONF_MAX_TEMPERATURE in visual:
add(climate_var.set_visual_max_temperature_override(visual[CONF_MAX_TEMPERATURE]))
if CONF_TEMPERATURE_STEP in visual:
add(climate_var.set_visual_temperature_step_override(visual[CONF_TEMPERATURE_STEP]))
setup_mqtt_component(climate_var.Pget_mqtt(), config)
def register_climate(var, config):
if not CORE.has_id(config[CONF_ID]):
var = Pvariable(config[CONF_ID], var, has_side_effects=True)
add(App.register_climate(var))
CORE.add_job(setup_climate_core_, var, config)
BUILD_FLAGS = '-DUSE_CLIMATE'
CONF_CLIMATE_CONTROL = 'climate.control'
CLIMATE_CONTROL_ACTION_SCHEMA = cv.Schema({
vol.Required(CONF_ID): cv.use_variable_id(ClimateDevice),
vol.Optional(CONF_MODE): cv.templatable(validate_climate_mode),
vol.Optional(CONF_TARGET_TEMPERATURE): cv.templatable(cv.temperature),
vol.Optional(CONF_TARGET_TEMPERATURE_LOW): cv.templatable(cv.temperature),
vol.Optional(CONF_TARGET_TEMPERATURE_HIGH): cv.templatable(cv.temperature),
vol.Optional(CONF_AWAY): cv.templatable(cv.boolean),
})
@ACTION_REGISTRY.register(CONF_CLIMATE_CONTROL, CLIMATE_CONTROL_ACTION_SCHEMA)
def climate_control_to_code(config, action_id, template_arg, args):
for var in get_variable(config[CONF_ID]):
yield None
rhs = var.make_control_action(template_arg)
type = ControlAction.template(template_arg)
action = Pvariable(action_id, rhs, type=type)
if CONF_MODE in config:
if isinstance(config[CONF_MODE], core.Lambda):
for template_ in templatable(config[CONF_MODE], args, ClimateMode):
yield None
add(action.set_mode(template_))
else:
add(action.set_mode(CLIMATE_MODES[config[CONF_MODE]]))
if CONF_TARGET_TEMPERATURE in config:
for template_ in templatable(config[CONF_TARGET_TEMPERATURE], args, float_):
yield None
add(action.set_target_temperature(template_))
if CONF_TARGET_TEMPERATURE_LOW in config:
for template_ in templatable(config[CONF_TARGET_TEMPERATURE_LOW], args, float_):
yield None
add(action.set_target_temperature_low(template_))
if CONF_TARGET_TEMPERATURE_HIGH in config:
for template_ in templatable(config[CONF_TARGET_TEMPERATURE_HIGH], args, float_):
yield None
add(action.set_target_temperature_high(template_))
if CONF_AWAY in config:
for template_ in templatable(config[CONF_AWAY], args, bool_):
yield None
add(action.set_away(template_))
yield action

View File

@ -1,66 +0,0 @@
import voluptuous as vol
from esphome import automation
from esphome.components import climate, sensor
import esphome.config_validation as cv
from esphome.const import CONF_AWAY_CONFIG, CONF_COOL_ACTION, \
CONF_DEFAULT_TARGET_TEMPERATURE_HIGH, \
CONF_DEFAULT_TARGET_TEMPERATURE_LOW, CONF_HEAT_ACTION, CONF_ID, CONF_IDLE_ACTION, CONF_SENSOR, \
CONF_NAME
from esphome.cpp_generator import Pvariable, add, get_variable
from esphome.cpp_helpers import setup_component
from esphome.cpp_types import App
BangBangClimate = climate.climate_ns.class_('BangBangClimate', climate.ClimateDevice)
BangBangClimateTargetTempConfig = climate.climate_ns.struct('BangBangClimateTargetTempConfig')
PLATFORM_SCHEMA = cv.nameable(climate.CLIMATE_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(BangBangClimate),
vol.Required(CONF_SENSOR): cv.use_variable_id(sensor.Sensor),
vol.Required(CONF_DEFAULT_TARGET_TEMPERATURE_LOW): cv.temperature,
vol.Required(CONF_DEFAULT_TARGET_TEMPERATURE_HIGH): cv.temperature,
vol.Required(CONF_IDLE_ACTION): automation.validate_automation(single=True),
vol.Optional(CONF_COOL_ACTION): automation.validate_automation(single=True),
vol.Optional(CONF_HEAT_ACTION): automation.validate_automation(single=True),
vol.Optional(CONF_AWAY_CONFIG): cv.Schema({
vol.Required(CONF_DEFAULT_TARGET_TEMPERATURE_LOW): cv.temperature,
vol.Required(CONF_DEFAULT_TARGET_TEMPERATURE_HIGH): cv.temperature,
}),
}).extend(cv.COMPONENT_SCHEMA.schema))
def to_code(config):
rhs = App.register_component(BangBangClimate.new(config[CONF_NAME]))
control = Pvariable(config[CONF_ID], rhs)
climate.register_climate(control, config)
setup_component(control, config)
for var in get_variable(config[CONF_SENSOR]):
yield
add(control.set_sensor(var))
normal_config = BangBangClimateTargetTempConfig(
config[CONF_DEFAULT_TARGET_TEMPERATURE_LOW],
config[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH]
)
add(control.set_normal_config(normal_config))
automation.build_automations(control.get_idle_trigger(), [], config[CONF_IDLE_ACTION])
if CONF_COOL_ACTION in config:
automation.build_automations(control.get_cool_trigger(), [], config[CONF_COOL_ACTION])
add(control.set_supports_cool(True))
if CONF_HEAT_ACTION in config:
automation.build_automations(control.get_heat_trigger(), [], config[CONF_HEAT_ACTION])
add(control.set_supports_heat(True))
if CONF_AWAY_CONFIG in config:
away = config[CONF_AWAY_CONFIG]
away_config = BangBangClimateTargetTempConfig(
away[CONF_DEFAULT_TARGET_TEMPERATURE_LOW],
away[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH]
)
add(control.set_away_config(away_config))
BUILD_FLAGS = '-DUSE_BANG_BANG_CLIMATE'

View File

@ -401,20 +401,6 @@ CONF_PINS = 'pins'
CONF_SENSORS = 'sensors'
CONF_BINARY_SENSORS = 'binary_sensors'
CONF_OUTPUTS = 'outputs'
CONF_VISUAL = 'visual'
CONF_MIN_TEMPERATURE = 'min_temperature'
CONF_MAX_TEMPERATURE = 'max_temperature'
CONF_TEMPERATURE_STEP = 'temperature_step'
CONF_TARGET_TEMPERATURE = 'target_temperature'
CONF_TARGET_TEMPERATURE_LOW = 'target_temperature_low'
CONF_DEFAULT_TARGET_TEMPERATURE_LOW = 'default_target_temperature_low'
CONF_TARGET_TEMPERATURE_HIGH = 'target_temperature_high'
CONF_DEFAULT_TARGET_TEMPERATURE_HIGH = 'default_target_temperature_high'
CONF_AWAY = 'away'
CONF_AWAY_CONFIG = 'away_config'
CONF_IDLE_ACTION = 'idle_action'
CONF_COOL_ACTION = 'cool_action'
CONF_HEAT_ACTION = 'heat_action'
CONF_SWITCHES = 'switches'
CONF_TEXT_SENSORS = 'text_sensors'
CONF_INCLUDES = 'includes'