Compare commits

...

12 Commits

Author SHA1 Message Date
Jesse Hills
c298c1166f Merge pull request #4567 from esphome/bump-2023.3.0b6
2023.3.0b6
2023-03-16 09:34:00 +13:00
Jesse Hills
c3d9eef01f Bump version to 2023.3.0b6 2023-03-16 08:57:54 +13:00
NP v/d Spek
5ffdc66864 fixing shrink and extend functions of the displaybuffer's Rect class (#4565)
* fixing rectangle's `shrink` and `extend`

* fixed the rect::shrink and rect::inside methods
and added rect:equal() method

* fixed internal clang issue again. When would is
this going to be fixed :(

* fixed internal clang issue again. When would is
this going to be fixed :(

* remove trailing space
2023-03-16 08:57:54 +13:00
Jesse Hills
9922c1503a Merge pull request #4564 from esphome/bump-2023.3.0b5
2023.3.0b5
2023-03-15 23:46:14 +13:00
Jesse Hills
fce99d4b17 Bump version to 2023.3.0b5 2023-03-15 21:20:08 +13:00
Jesse Hills
11567085d8 Mark esp32_touch supported only on standard esp32 variant (#4562)
* Mark esp32_touch supported only on standard esp32 variant

* Add back default
2023-03-15 21:20:08 +13:00
Keith Burzinski
83f8e84247 Remove switch actions during config; bump setup priority (#4563) 2023-03-15 21:20:08 +13:00
Jesse Hills
11eb5cb0fa Merge pull request #4559 from esphome/bump-2023.3.0b4
2023.3.0b4
2023-03-14 16:17:51 +13:00
Jesse Hills
9a7af97b2d Bump version to 2023.3.0b4 2023-03-14 14:11:55 +13:00
Stroe Andrei Catalin
5e11469f50 Added response for Tuya RSSI command (#4549)
* Added wifi rssi util
Added tuya mcu response to wifi rssi command

* Cleanup

* PR Comments

* PR Comments
2023-03-14 14:11:55 +13:00
DAVe3283
0c7a3d1fff Revert "Remove state class from uptime sensor (#4345)" (#4557)
This reverts commit 36c2e770bf.
Addresses esphome/issues#4193.
2023-03-14 14:11:55 +13:00
Eduardo Roldan
8a705bf4b0 pipsolar component. Correct the sscanf format for QPIG command parsing to set pv_input_voltage as float (not int) (#4165) 2023-03-14 14:11:55 +13:00
11 changed files with 81 additions and 48 deletions

View File

@@ -32,9 +32,11 @@ void Rect::extend(Rect rect) {
this->h = rect.h;
} else {
if (this->x > rect.x) {
this->w = this->w + (this->x - rect.x);
this->x = rect.x;
}
if (this->y > rect.y) {
this->h = this->h + (this->y - rect.y);
this->y = rect.y;
}
if (this->x2() < rect.x2()) {
@@ -49,29 +51,35 @@ void Rect::shrink(Rect rect) {
if (!this->inside(rect)) {
(*this) = Rect();
} else {
if (this->x < rect.x) {
this->x = rect.x;
}
if (this->y < rect.y) {
this->y = rect.y;
}
if (this->x2() > rect.x2()) {
this->w = rect.x2() - this->x;
}
if (this->x < rect.x) {
this->w = this->w + (this->x - rect.x);
this->x = rect.x;
}
if (this->y2() > rect.y2()) {
this->h = rect.y2() - this->y;
}
if (this->y < rect.y) {
this->h = this->h + (this->y - rect.y);
this->y = rect.y;
}
}
}
bool Rect::inside(int16_t x, int16_t y, bool absolute) { // NOLINT
bool Rect::equal(Rect rect) {
return (rect.x == this->x) && (rect.w == this->w) && (rect.y == this->y) && (rect.h == this->h);
}
bool Rect::inside(int16_t test_x, int16_t test_y, bool absolute) { // NOLINT
if (!this->is_set()) {
return true;
}
if (absolute) {
return ((x >= 0) && (x <= this->w) && (y >= 0) && (y <= this->h));
return ((test_x >= this->x) && (test_x <= this->x2()) && (test_y >= this->y) && (test_y <= this->y2()));
} else {
return ((x >= this->x) && (x <= this->x2()) && (y >= this->y) && (y <= this->y2()));
return ((test_x >= 0) && (test_x <= this->w) && (test_y >= 0) && (test_y <= this->h));
}
}
@@ -80,15 +88,16 @@ bool Rect::inside(Rect rect, bool absolute) {
return true;
}
if (absolute) {
return ((rect.x <= this->w) && (rect.w >= 0) && (rect.y <= this->h) && (rect.h >= 0));
} else {
return ((rect.x <= this->x2()) && (rect.x2() >= this->x) && (rect.y <= this->y2()) && (rect.y2() >= this->y));
} else {
return ((rect.x <= this->w) && (rect.w >= 0) && (rect.y <= this->h) && (rect.h >= 0));
}
}
void Rect::info(const std::string &prefix) {
if (this->is_set()) {
ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d]", prefix.c_str(), this->x, this->y, this->w, this->h);
ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d] (%3d,%3d)", prefix.c_str(), this->x, this->y, this->w, this->h, this->x2(),
this->y2());
} else
ESP_LOGI(TAG, "%s ** IS NOT SET **", prefix.c_str());
}

View File

@@ -120,8 +120,9 @@ class Rect {
void extend(Rect rect);
void shrink(Rect rect);
bool inside(Rect rect, bool absolute = false);
bool inside(int16_t x, int16_t y, bool absolute = false);
bool inside(Rect rect, bool absolute = true);
bool inside(int16_t test_x, int16_t test_y, bool absolute = true);
bool equal(Rect rect);
void info(const std::string &prefix = "rect info:");
};

View File

@@ -11,6 +11,7 @@ from esphome.const import (
CONF_VOLTAGE_ATTENUATION,
)
from esphome.core import TimePeriod
from esphome.components import esp32
AUTO_LOAD = ["binary_sensor"]
DEPENDENCIES = ["esp32"]
@@ -50,30 +51,37 @@ VOLTAGE_ATTENUATION = {
"0V": cg.global_ns.TOUCH_HVOLT_ATTEN_0V,
}
CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.declare_id(ESP32TouchComponent),
cv.Optional(CONF_SETUP_MODE, default=False): cv.boolean,
cv.Optional(
CONF_IIR_FILTER, default="0ms"
): cv.positive_time_period_milliseconds,
cv.Optional(CONF_SLEEP_DURATION, default="27306us"): cv.All(
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=436906))
),
cv.Optional(CONF_MEASUREMENT_DURATION, default="8192us"): cv.All(
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=8192))
),
cv.Optional(CONF_LOW_VOLTAGE_REFERENCE, default="0.5V"): validate_voltage(
LOW_VOLTAGE_REFERENCE
),
cv.Optional(CONF_HIGH_VOLTAGE_REFERENCE, default="2.7V"): validate_voltage(
HIGH_VOLTAGE_REFERENCE
),
cv.Optional(CONF_VOLTAGE_ATTENUATION, default="0V"): validate_voltage(
VOLTAGE_ATTENUATION
),
}
).extend(cv.COMPONENT_SCHEMA)
CONFIG_SCHEMA = cv.All(
cv.Schema(
{
cv.GenerateID(): cv.declare_id(ESP32TouchComponent),
cv.Optional(CONF_SETUP_MODE, default=False): cv.boolean,
cv.Optional(
CONF_IIR_FILTER, default="0ms"
): cv.positive_time_period_milliseconds,
cv.Optional(CONF_SLEEP_DURATION, default="27306us"): cv.All(
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=436906))
),
cv.Optional(CONF_MEASUREMENT_DURATION, default="8192us"): cv.All(
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=8192))
),
cv.Optional(CONF_LOW_VOLTAGE_REFERENCE, default="0.5V"): validate_voltage(
LOW_VOLTAGE_REFERENCE
),
cv.Optional(CONF_HIGH_VOLTAGE_REFERENCE, default="2.7V"): validate_voltage(
HIGH_VOLTAGE_REFERENCE
),
cv.Optional(CONF_VOLTAGE_ATTENUATION, default="0V"): validate_voltage(
VOLTAGE_ATTENUATION
),
}
).extend(cv.COMPONENT_SCHEMA),
esp32.only_on_variant(
supported=[
esp32.const.VARIANT_ESP32,
]
),
)
async def to_code(config):

View File

@@ -448,7 +448,7 @@ void Pipsolar::loop() {
ESP_LOGD(TAG, "Decode QPIGS");
sscanf( // NOLINT
tmp, // NOLINT
"(%f %f %f %f %d %d %d %d %f %d %d %d %d %f %f %d %1d%1d%1d%1d%1d%1d%1d%1d %d %d %d %1d%1d%1d", // NOLINT
"(%f %f %f %f %d %d %d %d %f %d %d %d %f %f %f %d %1d%1d%1d%1d%1d%1d%1d%1d %d %d %d %1d%1d%1d", // NOLINT
&value_grid_voltage_, &value_grid_frequency_, &value_ac_output_voltage_, // NOLINT
&value_ac_output_frequency_, // NOLINT
&value_ac_output_apparent_power_, &value_ac_output_active_power_, &value_output_load_percent_, // NOLINT

View File

@@ -65,7 +65,7 @@ class Pipsolar : public uart::UARTDevice, public PollingComponent {
PIPSOLAR_SENSOR(battery_charging_current, QPIGS, int)
PIPSOLAR_SENSOR(battery_capacity_percent, QPIGS, int)
PIPSOLAR_SENSOR(inverter_heat_sink_temperature, QPIGS, int)
PIPSOLAR_SENSOR(pv_input_current_for_battery, QPIGS, int)
PIPSOLAR_SENSOR(pv_input_current_for_battery, QPIGS, float)
PIPSOLAR_SENSOR(pv_input_voltage, QPIGS, float)
PIPSOLAR_SENSOR(battery_voltage_scc, QPIGS, float)
PIPSOLAR_SENSOR(battery_discharge_current, QPIGS, int)

View File

@@ -477,7 +477,6 @@ void Sprinkler::configure_valve_switch(size_t valve_number, switch_::Switch *val
if (this->is_a_valid_valve(valve_number)) {
this->valve_[valve_number].valve_switch.set_on_switch(valve_switch);
this->valve_[valve_number].run_duration = run_duration;
valve_switch->turn_off();
}
}
@@ -489,8 +488,6 @@ void Sprinkler::configure_valve_switch_pulsed(size_t valve_number, switch_::Swit
this->valve_[valve_number].valve_switch.set_on_switch(valve_switch_on);
this->valve_[valve_number].valve_switch.set_pulse_duration(pulse_duration);
this->valve_[valve_number].run_duration = run_duration;
valve_switch_off->turn_off();
valve_switch_on->turn_off();
}
}
@@ -505,7 +502,6 @@ void Sprinkler::configure_valve_pump_switch(size_t valve_number, switch_::Switch
this->pump_.resize(this->pump_.size() + 1);
this->pump_.back().set_on_switch(pump_switch);
this->valve_[valve_number].pump_switch_index = this->pump_.size() - 1; // save the index to the new pump
pump_switch->turn_off();
}
}
@@ -524,8 +520,6 @@ void Sprinkler::configure_valve_pump_switch_pulsed(size_t valve_number, switch_:
this->pump_.back().set_on_switch(pump_switch_on);
this->pump_.back().set_pulse_duration(pulse_duration);
this->valve_[valve_number].pump_switch_index = this->pump_.size() - 1; // save the index to the new pump
pump_switch_off->turn_off();
pump_switch_on->turn_off();
}
}

View File

@@ -103,7 +103,7 @@ class SprinklerControllerNumber : public number::Number, public Component {
public:
void setup() override;
void dump_config() override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
float get_setup_priority() const override { return setup_priority::PROCESSOR; }
Trigger<float> *get_set_trigger() const { return set_trigger_; }
void set_initial_value(float initial_value) { initial_value_ = initial_value; }

View File

@@ -5,6 +5,10 @@
#include "esphome/core/util.h"
#include "esphome/core/gpio.h"
#ifdef USE_WIFI
#include "esphome/components/wifi/wifi_component.h"
#endif
#ifdef USE_CAPTIVE_PORTAL
#include "esphome/components/captive_portal/captive_portal.h"
#endif
@@ -234,6 +238,10 @@ void Tuya::handle_command_(uint8_t command, uint8_t version, const uint8_t *buff
case TuyaCommandType::WIFI_TEST:
this->send_command_(TuyaCommand{.cmd = TuyaCommandType::WIFI_TEST, .payload = std::vector<uint8_t>{0x00, 0x00}});
break;
case TuyaCommandType::WIFI_RSSI:
this->send_command_(
TuyaCommand{.cmd = TuyaCommandType::WIFI_RSSI, .payload = std::vector<uint8_t>{get_wifi_rssi_()}});
break;
case TuyaCommandType::LOCAL_TIME_QUERY:
#ifdef USE_TIME
if (this->time_id_.has_value()) {
@@ -475,6 +483,15 @@ uint8_t Tuya::get_wifi_status_code_() {
return status;
}
uint8_t Tuya::get_wifi_rssi_() {
#ifdef USE_WIFI
if (wifi::global_wifi_component != nullptr)
return wifi::global_wifi_component->wifi_rssi();
#endif
return 0;
}
void Tuya::send_wifi_status_() {
uint8_t status = this->get_wifi_status_code_();

View File

@@ -55,6 +55,7 @@ enum class TuyaCommandType : uint8_t {
DATAPOINT_QUERY = 0x08,
WIFI_TEST = 0x0E,
LOCAL_TIME_QUERY = 0x1C,
WIFI_RSSI = 0x24,
VACUUM_MAP_UPLOAD = 0x28,
GET_NETWORK_STATUS = 0x2B,
};
@@ -123,6 +124,7 @@ class Tuya : public Component, public uart::UARTDevice {
void set_status_pin_();
void send_wifi_status_();
uint8_t get_wifi_status_code_();
uint8_t get_wifi_rssi_();
#ifdef USE_TIME
void send_local_time_();

View File

@@ -3,6 +3,7 @@ import esphome.config_validation as cv
from esphome.components import sensor
from esphome.const import (
ENTITY_CATEGORY_DIAGNOSTIC,
STATE_CLASS_TOTAL_INCREASING,
UNIT_SECOND,
ICON_TIMER,
DEVICE_CLASS_DURATION,
@@ -16,6 +17,7 @@ CONFIG_SCHEMA = sensor.sensor_schema(
unit_of_measurement=UNIT_SECOND,
icon=ICON_TIMER,
accuracy_decimals=0,
state_class=STATE_CLASS_TOTAL_INCREASING,
device_class=DEVICE_CLASS_DURATION,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
).extend(cv.polling_component_schema("60s"))

View File

@@ -1,6 +1,6 @@
"""Constants used by esphome."""
__version__ = "2023.3.0b3"
__version__ = "2023.3.0b6"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"