From 5fecc70db1afaae958d8138e02ac6abb1d602fb9 Mon Sep 17 00:00:00 2001 From: Guillermo Ruffino Date: Tue, 1 Sep 2020 19:15:26 -0300 Subject: [PATCH 1/4] fix sntp timezone (#1266) --- esphome/components/sntp/sntp_component.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/esphome/components/sntp/sntp_component.cpp b/esphome/components/sntp/sntp_component.cpp index c10a3e5ac3..253f3ba2c1 100644 --- a/esphome/components/sntp/sntp_component.cpp +++ b/esphome/components/sntp/sntp_component.cpp @@ -33,10 +33,6 @@ void SNTPComponent::setup() { sntp_setservername(2, strdup(this->server_3_.c_str())); } -#ifdef ARDUINO_ARCH_ESP8266 - // let localtime/gmtime handle timezones, not sntp - sntp_set_timezone(0); -#endif sntp_init(); } void SNTPComponent::dump_config() { From 9c5b693dd5bb2872c31a775ee7c65ddb11e01c51 Mon Sep 17 00:00:00 2001 From: akoivist <35623281+akoivist@users.noreply.github.com> Date: Wed, 2 Sep 2020 01:17:15 +0300 Subject: [PATCH 2/4] Fix for Ruuvi voltage parsing of RAWv2 format (#1267) Power_info should be 2 bytes, so changed uint8 to uint16. With uint8 voltage is always reported to be near 1.6V. --- esphome/components/ruuvi_ble/ruuvi_ble.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/ruuvi_ble/ruuvi_ble.cpp b/esphome/components/ruuvi_ble/ruuvi_ble.cpp index 7e13140e55..897e4a2504 100644 --- a/esphome/components/ruuvi_ble/ruuvi_ble.cpp +++ b/esphome/components/ruuvi_ble/ruuvi_ble.cpp @@ -50,7 +50,7 @@ bool parse_ruuvi_data_byte(const esp32_ble_tracker::adv_data_t &adv_data, RuuviP const float acceleration_y = (int16_t(data[8] << 8) + int16_t(data[9])) / 1000.0f; const float acceleration_z = (int16_t(data[10] << 8) + int16_t(data[11])) / 1000.0f; - const uint8_t power_info = (data[12] << 8) | data[13]; + const uint16_t power_info = (uint16_t(data[12] << 8) | data[13]); const float battery_voltage = ((power_info >> 5) + 1600.0f) / 1000.0f; const float tx_power = ((power_info & 0x1F) * 2.0f) - 40.0f; From 1d064262817d646f54986751fd12057401f9f674 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 15 Sep 2020 10:33:37 +1200 Subject: [PATCH 3/4] Adds support for Tuya Climate temperature multiplier (#1276) * Adds support for temperature multiplier * Add new multiplier to test file * Remove import * Fixes --- esphome/components/tuya/climate/__init__.py | 11 +++--- .../components/tuya/climate/tuya_climate.cpp | 38 ++++--------------- .../components/tuya/climate/tuya_climate.h | 6 ++- tests/test4.yaml | 1 + 4 files changed, 17 insertions(+), 39 deletions(-) diff --git a/esphome/components/tuya/climate/__init__.py b/esphome/components/tuya/climate/__init__.py index 878c5aefe8..79c6551c14 100644 --- a/esphome/components/tuya/climate/__init__.py +++ b/esphome/components/tuya/climate/__init__.py @@ -7,9 +7,9 @@ from .. import tuya_ns, CONF_TUYA_ID, Tuya DEPENDENCIES = ['tuya'] CODEOWNERS = ['@jesserockz'] -CONF_TARGET_TEMPERATURE_DATAPOINT = "target_temperature_datapoint" -CONF_CURRENT_TEMPERATURE_DATAPOINT = "current_temperature_datapoint" -# CONF_ECO_MODE_DATAPOINT = "eco_mode_datapoint" +CONF_TARGET_TEMPERATURE_DATAPOINT = 'target_temperature_datapoint' +CONF_CURRENT_TEMPERATURE_DATAPOINT = 'current_temperature_datapoint' +CONF_TEMPERATURE_MULTIPLIER = 'temperature_multiplier' TuyaClimate = tuya_ns.class_('TuyaClimate', climate.Climate, cg.Component) @@ -19,7 +19,7 @@ CONFIG_SCHEMA = cv.All(climate.CLIMATE_SCHEMA.extend({ cv.Optional(CONF_SWITCH_DATAPOINT): cv.uint8_t, cv.Optional(CONF_TARGET_TEMPERATURE_DATAPOINT): cv.uint8_t, cv.Optional(CONF_CURRENT_TEMPERATURE_DATAPOINT): cv.uint8_t, - # cv.Optional(CONF_ECO_MODE_DATAPOINT): cv.uint8_t, + cv.Optional(CONF_TEMPERATURE_MULTIPLIER, default=1): cv.positive_float, }).extend(cv.COMPONENT_SCHEMA), cv.has_at_least_one_key( CONF_TARGET_TEMPERATURE_DATAPOINT, CONF_SWITCH_DATAPOINT)) @@ -38,5 +38,4 @@ def to_code(config): cg.add(var.set_target_temperature_id(config[CONF_TARGET_TEMPERATURE_DATAPOINT])) if CONF_CURRENT_TEMPERATURE_DATAPOINT in config: cg.add(var.set_current_temperature_id(config[CONF_CURRENT_TEMPERATURE_DATAPOINT])) - # if CONF_ECO_MODE_DATAPOINT in config: - # cg.add(var.set_eco_mode_id(config[CONF_ECO_MODE_DATAPOINT])) + cg.add(var.set_temperature_multiplier(config[CONF_TEMPERATURE_MULTIPLIER])) diff --git a/esphome/components/tuya/climate/tuya_climate.cpp b/esphome/components/tuya/climate/tuya_climate.cpp index cfd5acccbd..0b66a58af6 100644 --- a/esphome/components/tuya/climate/tuya_climate.cpp +++ b/esphome/components/tuya/climate/tuya_climate.cpp @@ -21,28 +21,20 @@ void TuyaClimate::setup() { } if (this->target_temperature_id_.has_value()) { this->parent_->register_listener(*this->target_temperature_id_, [this](TuyaDatapoint datapoint) { - this->target_temperature = datapoint.value_int; + this->target_temperature = datapoint.value_int * this->temperature_multiplier_; this->compute_state_(); this->publish_state(); - ESP_LOGD(TAG, "MCU reported target temperature is: %d", datapoint.value_int); + ESP_LOGD(TAG, "MCU reported target temperature is: %.1f", this->target_temperature); }); } if (this->current_temperature_id_.has_value()) { this->parent_->register_listener(*this->current_temperature_id_, [this](TuyaDatapoint datapoint) { - this->current_temperature = datapoint.value_int; + this->current_temperature = datapoint.value_int * this->temperature_multiplier_; this->compute_state_(); this->publish_state(); - ESP_LOGD(TAG, "MCU reported current temperature is: %d", datapoint.value_int); + ESP_LOGD(TAG, "MCU reported current temperature is: %.1f", this->current_temperature); }); } - // if (this->eco_mode_id_.has_value()) { - // this->parent_->register_listener(*this->eco_mode_id_, [this](TuyaDatapoint datapoint) { - // this->eco_mode = datapoint.value_bool; - // this->compute_state_(); - // this->publish_state(); - // ESP_LOGD(TAG, "MCU reported eco mode of: %s", ONOFF(datapoint.value_bool)); - // }); - // } } void TuyaClimate::control(const climate::ClimateCall &call) { @@ -56,30 +48,17 @@ void TuyaClimate::control(const climate::ClimateCall &call) { this->parent_->set_datapoint_value(datapoint); ESP_LOGD(TAG, "Setting switch: %s", ONOFF(datapoint.value_bool)); } - if (call.get_target_temperature_low().has_value()) - this->target_temperature_low = *call.get_target_temperature_low(); - if (call.get_target_temperature_high().has_value()) - this->target_temperature_high = *call.get_target_temperature_high(); + if (call.get_target_temperature().has_value()) { this->target_temperature = *call.get_target_temperature(); TuyaDatapoint datapoint{}; datapoint.id = *this->target_temperature_id_; datapoint.type = TuyaDatapointType::INTEGER; - datapoint.value_int = (int) this->target_temperature; + datapoint.value_int = (int) (this->target_temperature / this->temperature_multiplier_); this->parent_->set_datapoint_value(datapoint); - ESP_LOGD(TAG, "Setting target temperature: %d", datapoint.value_int); + ESP_LOGD(TAG, "Setting target temperature: %.1f", this->target_temperature); } - // if (call.get_eco_mode().has_value()) { - // this->eco_mode = *call.get_eco_mode(); - - // TuyaDatapoint datapoint{}; - // datapoint.id = *this->eco_mode_id_; - // datapoint.type = TuyaDatapointType::BOOLEAN; - // datapoint.value_bool = this->eco_mode; - // this->parent_->set_datapoint_value(datapoint); - // ESP_LOGD(TAG, "Setting eco mode: %s", ONOFF(datapoint.value_bool)); - // } this->compute_state_(); this->publish_state(); @@ -89,7 +68,6 @@ climate::ClimateTraits TuyaClimate::traits() { auto traits = climate::ClimateTraits(); traits.set_supports_current_temperature(this->current_temperature_id_.has_value()); traits.set_supports_heat_mode(true); - // traits.set_supports_eco_mode(this->eco_mode_id_.has_value()); traits.set_supports_action(true); return traits; } @@ -102,8 +80,6 @@ void TuyaClimate::dump_config() { ESP_LOGCONFIG(TAG, " Target Temperature has datapoint ID %u", *this->target_temperature_id_); if (this->current_temperature_id_.has_value()) ESP_LOGCONFIG(TAG, " Current Temperature has datapoint ID %u", *this->current_temperature_id_); - // if (this->eco_mode_id_.has_value()) - // ESP_LOGCONFIG(TAG, " Eco Mode has datapoint ID %u", *this->mode_id_); } void TuyaClimate::compute_state_() { diff --git a/esphome/components/tuya/climate/tuya_climate.h b/esphome/components/tuya/climate/tuya_climate.h index a073b0996c..e09e110a35 100644 --- a/esphome/components/tuya/climate/tuya_climate.h +++ b/esphome/components/tuya/climate/tuya_climate.h @@ -18,7 +18,9 @@ class TuyaClimate : public climate::Climate, public Component { void set_current_temperature_id(uint8_t current_temperature_id) { this->current_temperature_id_ = current_temperature_id; } - // void set_eco_mode_id(uint8_t eco_mode_id) { this->eco_mode_id_ = eco_mode_id; } + void set_temperature_multiplier(float temperature_multiplier) { + this->temperature_multiplier_ = temperature_multiplier; + } void set_tuya_parent(Tuya *parent) { this->parent_ = parent; } @@ -38,7 +40,7 @@ class TuyaClimate : public climate::Climate, public Component { optional switch_id_{}; optional target_temperature_id_{}; optional current_temperature_id_{}; - // optional eco_mode_id_{}; + float temperature_multiplier_{1.0f}; }; } // namespace tuya diff --git a/tests/test4.yaml b/tests/test4.yaml index 61c1e278c4..74c898a410 100644 --- a/tests/test4.yaml +++ b/tests/test4.yaml @@ -87,6 +87,7 @@ climate: id: tuya_climate switch_datapoint: 1 target_temperature_datapoint: 3 + temperature_multiplier: 0.5 switch: - platform: tuya From c50da1593aeaab36ccf9c2ae89d942357da654df Mon Sep 17 00:00:00 2001 From: Guillermo Ruffino Date: Mon, 14 Sep 2020 21:39:08 -0300 Subject: [PATCH 4/4] Bump version to v1.15.1 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 61c3044fe6..478f5bb94b 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -2,7 +2,7 @@ MAJOR_VERSION = 1 MINOR_VERSION = 15 -PATCH_VERSION = '0' +PATCH_VERSION = '1' __short_version__ = f'{MAJOR_VERSION}.{MINOR_VERSION}' __version__ = f'{__short_version__}.{PATCH_VERSION}'