mirror of
https://github.com/esphome/esphome.git
synced 2024-12-01 13:13:54 +01:00
Merge branch 'esphome:dev' into optolink
This commit is contained in:
commit
8ac704bbe0
@ -11,6 +11,7 @@ from esphome.const import (
|
|||||||
CONF_VOLTAGE_ATTENUATION,
|
CONF_VOLTAGE_ATTENUATION,
|
||||||
)
|
)
|
||||||
from esphome.core import TimePeriod
|
from esphome.core import TimePeriod
|
||||||
|
from esphome.components import esp32
|
||||||
|
|
||||||
AUTO_LOAD = ["binary_sensor"]
|
AUTO_LOAD = ["binary_sensor"]
|
||||||
DEPENDENCIES = ["esp32"]
|
DEPENDENCIES = ["esp32"]
|
||||||
@ -50,30 +51,37 @@ VOLTAGE_ATTENUATION = {
|
|||||||
"0V": cg.global_ns.TOUCH_HVOLT_ATTEN_0V,
|
"0V": cg.global_ns.TOUCH_HVOLT_ATTEN_0V,
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.All(
|
||||||
{
|
cv.Schema(
|
||||||
cv.GenerateID(): cv.declare_id(ESP32TouchComponent),
|
{
|
||||||
cv.Optional(CONF_SETUP_MODE, default=False): cv.boolean,
|
cv.GenerateID(): cv.declare_id(ESP32TouchComponent),
|
||||||
cv.Optional(
|
cv.Optional(CONF_SETUP_MODE, default=False): cv.boolean,
|
||||||
CONF_IIR_FILTER, default="0ms"
|
cv.Optional(
|
||||||
): cv.positive_time_period_milliseconds,
|
CONF_IIR_FILTER, default="0ms"
|
||||||
cv.Optional(CONF_SLEEP_DURATION, default="27306us"): cv.All(
|
): cv.positive_time_period_milliseconds,
|
||||||
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=436906))
|
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_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_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_HIGH_VOLTAGE_REFERENCE, default="2.7V"): validate_voltage(
|
||||||
),
|
HIGH_VOLTAGE_REFERENCE
|
||||||
cv.Optional(CONF_VOLTAGE_ATTENUATION, default="0V"): validate_voltage(
|
),
|
||||||
VOLTAGE_ATTENUATION
|
cv.Optional(CONF_VOLTAGE_ATTENUATION, default="0V"): validate_voltage(
|
||||||
),
|
VOLTAGE_ATTENUATION
|
||||||
}
|
),
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
}
|
||||||
|
).extend(cv.COMPONENT_SCHEMA),
|
||||||
|
esp32.only_on_variant(
|
||||||
|
supported=[
|
||||||
|
esp32.const.VARIANT_ESP32,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
|
@ -477,7 +477,6 @@ void Sprinkler::configure_valve_switch(size_t valve_number, switch_::Switch *val
|
|||||||
if (this->is_a_valid_valve(valve_number)) {
|
if (this->is_a_valid_valve(valve_number)) {
|
||||||
this->valve_[valve_number].valve_switch.set_on_switch(valve_switch);
|
this->valve_[valve_number].valve_switch.set_on_switch(valve_switch);
|
||||||
this->valve_[valve_number].run_duration = run_duration;
|
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_on_switch(valve_switch_on);
|
||||||
this->valve_[valve_number].valve_switch.set_pulse_duration(pulse_duration);
|
this->valve_[valve_number].valve_switch.set_pulse_duration(pulse_duration);
|
||||||
this->valve_[valve_number].run_duration = run_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_.resize(this->pump_.size() + 1);
|
||||||
this->pump_.back().set_on_switch(pump_switch);
|
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
|
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_on_switch(pump_switch_on);
|
||||||
this->pump_.back().set_pulse_duration(pulse_duration);
|
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
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class SprinklerControllerNumber : public number::Number, public Component {
|
|||||||
public:
|
public:
|
||||||
void setup() override;
|
void setup() override;
|
||||||
void dump_config() 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_; }
|
Trigger<float> *get_set_trigger() const { return set_trigger_; }
|
||||||
void set_initial_value(float initial_value) { initial_value_ = initial_value; }
|
void set_initial_value(float initial_value) { initial_value_ = initial_value; }
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
#include "esphome/core/util.h"
|
#include "esphome/core/util.h"
|
||||||
#include "esphome/core/gpio.h"
|
#include "esphome/core/gpio.h"
|
||||||
|
|
||||||
|
#ifdef USE_WIFI
|
||||||
|
#include "esphome/components/wifi/wifi_component.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_CAPTIVE_PORTAL
|
#ifdef USE_CAPTIVE_PORTAL
|
||||||
#include "esphome/components/captive_portal/captive_portal.h"
|
#include "esphome/components/captive_portal/captive_portal.h"
|
||||||
#endif
|
#endif
|
||||||
@ -234,6 +238,10 @@ void Tuya::handle_command_(uint8_t command, uint8_t version, const uint8_t *buff
|
|||||||
case TuyaCommandType::WIFI_TEST:
|
case TuyaCommandType::WIFI_TEST:
|
||||||
this->send_command_(TuyaCommand{.cmd = TuyaCommandType::WIFI_TEST, .payload = std::vector<uint8_t>{0x00, 0x00}});
|
this->send_command_(TuyaCommand{.cmd = TuyaCommandType::WIFI_TEST, .payload = std::vector<uint8_t>{0x00, 0x00}});
|
||||||
break;
|
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:
|
case TuyaCommandType::LOCAL_TIME_QUERY:
|
||||||
#ifdef USE_TIME
|
#ifdef USE_TIME
|
||||||
if (this->time_id_.has_value()) {
|
if (this->time_id_.has_value()) {
|
||||||
@ -475,6 +483,15 @@ uint8_t Tuya::get_wifi_status_code_() {
|
|||||||
return status;
|
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_() {
|
void Tuya::send_wifi_status_() {
|
||||||
uint8_t status = this->get_wifi_status_code_();
|
uint8_t status = this->get_wifi_status_code_();
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ enum class TuyaCommandType : uint8_t {
|
|||||||
DATAPOINT_QUERY = 0x08,
|
DATAPOINT_QUERY = 0x08,
|
||||||
WIFI_TEST = 0x0E,
|
WIFI_TEST = 0x0E,
|
||||||
LOCAL_TIME_QUERY = 0x1C,
|
LOCAL_TIME_QUERY = 0x1C,
|
||||||
|
WIFI_RSSI = 0x24,
|
||||||
VACUUM_MAP_UPLOAD = 0x28,
|
VACUUM_MAP_UPLOAD = 0x28,
|
||||||
GET_NETWORK_STATUS = 0x2B,
|
GET_NETWORK_STATUS = 0x2B,
|
||||||
};
|
};
|
||||||
@ -123,6 +124,7 @@ class Tuya : public Component, public uart::UARTDevice {
|
|||||||
void set_status_pin_();
|
void set_status_pin_();
|
||||||
void send_wifi_status_();
|
void send_wifi_status_();
|
||||||
uint8_t get_wifi_status_code_();
|
uint8_t get_wifi_status_code_();
|
||||||
|
uint8_t get_wifi_rssi_();
|
||||||
|
|
||||||
#ifdef USE_TIME
|
#ifdef USE_TIME
|
||||||
void send_local_time_();
|
void send_local_time_();
|
||||||
|
@ -3,6 +3,7 @@ import esphome.config_validation as cv
|
|||||||
from esphome.components import sensor
|
from esphome.components import sensor
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
UNIT_SECOND,
|
UNIT_SECOND,
|
||||||
ICON_TIMER,
|
ICON_TIMER,
|
||||||
DEVICE_CLASS_DURATION,
|
DEVICE_CLASS_DURATION,
|
||||||
@ -16,6 +17,7 @@ CONFIG_SCHEMA = sensor.sensor_schema(
|
|||||||
unit_of_measurement=UNIT_SECOND,
|
unit_of_measurement=UNIT_SECOND,
|
||||||
icon=ICON_TIMER,
|
icon=ICON_TIMER,
|
||||||
accuracy_decimals=0,
|
accuracy_decimals=0,
|
||||||
|
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||||
device_class=DEVICE_CLASS_DURATION,
|
device_class=DEVICE_CLASS_DURATION,
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
).extend(cv.polling_component_schema("60s"))
|
).extend(cv.polling_component_schema("60s"))
|
||||||
|
Loading…
Reference in New Issue
Block a user