Register components properly

This commit is contained in:
Otto Winter 2019-05-24 16:20:28 +02:00
parent 999c1a5357
commit bd45f6bd8e
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
6 changed files with 14 additions and 12 deletions

View file

@ -7,7 +7,7 @@ from esphome.const import CONF_AWAY_CONFIG, CONF_COOL_ACTION, \
CONF_ID, CONF_IDLE_ACTION, CONF_SENSOR CONF_ID, CONF_IDLE_ACTION, CONF_SENSOR
bang_bang_ns = cg.esphome_ns.namespace('bang_bang') bang_bang_ns = cg.esphome_ns.namespace('bang_bang')
BangBangClimate = bang_bang_ns.class_('BangBangClimate', climate.Climate) BangBangClimate = bang_bang_ns.class_('BangBangClimate', climate.Climate, cg.Component)
BangBangClimateTargetTempConfig = bang_bang_ns.struct('BangBangClimateTargetTempConfig') BangBangClimateTargetTempConfig = bang_bang_ns.struct('BangBangClimateTargetTempConfig')
CONFIG_SCHEMA = cv.All(climate.CLIMATE_SCHEMA.extend({ CONFIG_SCHEMA = cv.All(climate.CLIMATE_SCHEMA.extend({

View file

@ -6,13 +6,13 @@ namespace climate {
const char *climate_mode_to_string(ClimateMode mode) { const char *climate_mode_to_string(ClimateMode mode) {
switch (mode) { switch (mode) {
case CLIMATE_MODE_OFF: case CLIMATE_MODE_OFF:
return "off"; return "OFF";
case CLIMATE_MODE_AUTO: case CLIMATE_MODE_AUTO:
return "auto"; return "AUTO";
case CLIMATE_MODE_COOL: case CLIMATE_MODE_COOL:
return "cool"; return "COOL";
case CLIMATE_MODE_HEAT: case CLIMATE_MODE_HEAT:
return "heat"; return "HEAT";
default: default:
return "UNKNOWN"; return "UNKNOWN";
} }

View file

@ -19,7 +19,7 @@ void DeepSleepComponent::setup() {
void DeepSleepComponent::dump_config() { void DeepSleepComponent::dump_config() {
ESP_LOGCONFIG(TAG, "Setting up Deep Sleep..."); ESP_LOGCONFIG(TAG, "Setting up Deep Sleep...");
if (this->sleep_duration_.has_value()) { if (this->sleep_duration_.has_value()) {
ESP_LOGCONFIG(TAG, " Sleep Duration: %llu ms", *this->sleep_duration_ / 1000); ESP_LOGCONFIG(TAG, " Sleep Duration: %u ms", *this->sleep_duration_ / 1000);
} }
if (this->run_duration_.has_value()) { if (this->run_duration_.has_value()) {
ESP_LOGCONFIG(TAG, " Run Duration: %u ms", *this->run_duration_); ESP_LOGCONFIG(TAG, " Run Duration: %u ms", *this->run_duration_);

View file

@ -6,7 +6,8 @@ from .. import homeassistant_ns
DEPENDENCIES = ['api'] DEPENDENCIES = ['api']
HomeassistantBinarySensor = homeassistant_ns.class_('HomeassistantBinarySensor', HomeassistantBinarySensor = homeassistant_ns.class_('HomeassistantBinarySensor',
binary_sensor.BinarySensor) binary_sensor.BinarySensor,
cg.Component)
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({
cv.GenerateID(): cv.declare_id(HomeassistantBinarySensor), cv.GenerateID(): cv.declare_id(HomeassistantBinarySensor),

View file

@ -6,7 +6,8 @@ from .. import homeassistant_ns
DEPENDENCIES = ['api'] DEPENDENCIES = ['api']
HomeassistantSensor = homeassistant_ns.class_('HomeassistantSensor', sensor.Sensor) HomeassistantSensor = homeassistant_ns.class_('HomeassistantSensor', sensor.Sensor,
cg.Component)
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({ CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
cv.GenerateID(): cv.declare_id(HomeassistantSensor), cv.GenerateID(): cv.declare_id(HomeassistantSensor),

View file

@ -24,12 +24,12 @@ void MQTTClimateComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryC
JsonArray &modes = root.createNestedArray("modes"); JsonArray &modes = root.createNestedArray("modes");
// sort array for nice UI in HA // sort array for nice UI in HA
if (traits.supports_mode(CLIMATE_MODE_AUTO)) if (traits.supports_mode(CLIMATE_MODE_AUTO))
modes.add(climate_mode_to_string(CLIMATE_MODE_AUTO)); modes.add("auto");
modes.add(climate_mode_to_string(CLIMATE_MODE_OFF)); modes.add("off");
if (traits.supports_mode(CLIMATE_MODE_COOL)) if (traits.supports_mode(CLIMATE_MODE_COOL))
modes.add(climate_mode_to_string(CLIMATE_MODE_COOL)); modes.add("cool");
if (traits.supports_mode(CLIMATE_MODE_HEAT)) if (traits.supports_mode(CLIMATE_MODE_HEAT))
modes.add(climate_mode_to_string(CLIMATE_MODE_HEAT)); modes.add("heat");
if (traits.get_supports_two_point_target_temperature()) { if (traits.get_supports_two_point_target_temperature()) {
// temperature_low_command_topic // temperature_low_command_topic