mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
commit
8c75b87e94
12 changed files with 29 additions and 4 deletions
|
@ -448,6 +448,7 @@ message LightCommandRequest {
|
|||
enum SensorStateClass {
|
||||
STATE_CLASS_NONE = 0;
|
||||
STATE_CLASS_MEASUREMENT = 1;
|
||||
STATE_CLASS_TOTAL_INCREASING = 2;
|
||||
}
|
||||
|
||||
enum SensorLastResetType {
|
||||
|
|
|
@ -94,6 +94,8 @@ template<> const char *proto_enum_to_string<enums::SensorStateClass>(enums::Sens
|
|||
return "STATE_CLASS_NONE";
|
||||
case enums::STATE_CLASS_MEASUREMENT:
|
||||
return "STATE_CLASS_MEASUREMENT";
|
||||
case enums::STATE_CLASS_TOTAL_INCREASING:
|
||||
return "STATE_CLASS_TOTAL_INCREASING";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ enum ColorMode : uint32_t {
|
|||
enum SensorStateClass : uint32_t {
|
||||
STATE_CLASS_NONE = 0,
|
||||
STATE_CLASS_MEASUREMENT = 1,
|
||||
STATE_CLASS_TOTAL_INCREASING = 2,
|
||||
};
|
||||
enum SensorLastResetType : uint32_t {
|
||||
LAST_RESET_NONE = 0,
|
||||
|
|
|
@ -5,6 +5,7 @@ from esphome.const import (
|
|||
DEVICE_CLASS_CURRENT,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
ICON_EMPTY,
|
||||
|
@ -178,7 +179,7 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
"m³",
|
||||
ICON_EMPTY,
|
||||
3,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_GAS,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
LAST_RESET_TYPE_NEVER,
|
||||
),
|
||||
|
@ -186,7 +187,7 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
"m³",
|
||||
ICON_EMPTY,
|
||||
3,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_GAS,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
LAST_RESET_TYPE_NEVER,
|
||||
),
|
||||
|
|
|
@ -19,6 +19,8 @@ class HBridgeLightOutput : public PollingComponent, public light::LightOutput {
|
|||
light::LightTraits get_traits() override {
|
||||
auto traits = light::LightTraits();
|
||||
traits.set_supported_color_modes({light::ColorMode::COLD_WARM_WHITE});
|
||||
traits.set_min_mireds(153);
|
||||
traits.set_max_mireds(500);
|
||||
return traits;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,13 @@ void LightState::setup() {
|
|||
effect->init_internal(this);
|
||||
}
|
||||
|
||||
// When supported color temperature range is known, initialize color temperature setting within bounds.
|
||||
float min_mireds = this->get_traits().get_min_mireds();
|
||||
if (min_mireds > 0) {
|
||||
this->remote_values.set_color_temperature(min_mireds);
|
||||
this->current_values.set_color_temperature(min_mireds);
|
||||
}
|
||||
|
||||
auto call = this->make_call();
|
||||
LightStateRTCState recovered{};
|
||||
switch (this->restore_mode_) {
|
||||
|
|
|
@ -543,6 +543,7 @@ void Nextion::process_nextion_commands_() {
|
|||
ESP_LOGVV(TAG, "Received Nextion leaves sleep automatically");
|
||||
this->is_sleeping_ = false;
|
||||
this->wake_callback_.call();
|
||||
this->all_components_send_state_(false);
|
||||
break;
|
||||
}
|
||||
case 0x88: // system successful start up
|
||||
|
|
|
@ -40,6 +40,7 @@ from esphome.const import (
|
|||
DEVICE_CLASS_CARBON_DIOXIDE,
|
||||
DEVICE_CLASS_CURRENT,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_MONETARY,
|
||||
|
@ -62,6 +63,7 @@ DEVICE_CLASSES = [
|
|||
DEVICE_CLASS_CARBON_DIOXIDE,
|
||||
DEVICE_CLASS_CURRENT,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_MONETARY,
|
||||
|
@ -79,6 +81,7 @@ StateClasses = sensor_ns.enum("StateClass")
|
|||
STATE_CLASSES = {
|
||||
"": StateClasses.STATE_CLASS_NONE,
|
||||
"measurement": StateClasses.STATE_CLASS_MEASUREMENT,
|
||||
"total_increasing": StateClasses.STATE_CLASS_TOTAL_INCREASING,
|
||||
}
|
||||
validate_state_class = cv.enum(STATE_CLASSES, lower=True, space="_")
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ const char *state_class_to_string(StateClass state_class) {
|
|||
switch (state_class) {
|
||||
case STATE_CLASS_MEASUREMENT:
|
||||
return "measurement";
|
||||
case STATE_CLASS_TOTAL_INCREASING:
|
||||
return "total_increasing";
|
||||
case STATE_CLASS_NONE:
|
||||
default:
|
||||
return "";
|
||||
|
@ -72,6 +74,8 @@ void Sensor::set_state_class(StateClass state_class) { this->state_class = state
|
|||
void Sensor::set_state_class(const std::string &state_class) {
|
||||
if (str_equals_case_insensitive(state_class, "measurement")) {
|
||||
this->state_class = STATE_CLASS_MEASUREMENT;
|
||||
} else if (str_equals_case_insensitive(state_class, "total_increasing")) {
|
||||
this->state_class = STATE_CLASS_TOTAL_INCREASING;
|
||||
} else {
|
||||
ESP_LOGW(TAG, "'%s' - Unrecognized state class %s", this->get_name().c_str(), state_class.c_str());
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace sensor {
|
|||
enum StateClass : uint8_t {
|
||||
STATE_CLASS_NONE = 0,
|
||||
STATE_CLASS_MEASUREMENT = 1,
|
||||
STATE_CLASS_TOTAL_INCREASING = 2,
|
||||
};
|
||||
|
||||
const char *state_class_to_string(StateClass state_class);
|
||||
|
|
|
@ -20,7 +20,6 @@ TotalDailyEnergy = total_daily_energy_ns.class_(
|
|||
|
||||
CONFIG_SCHEMA = (
|
||||
sensor.sensor_schema(
|
||||
accuracy_decimals=0,
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
last_reset_type=LAST_RESET_TYPE_AUTO,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "1.21.0b2"
|
||||
__version__ = "1.21.0b3"
|
||||
|
||||
ESP_PLATFORM_ESP32 = "ESP32"
|
||||
ESP_PLATFORM_ESP8266 = "ESP8266"
|
||||
|
@ -840,6 +840,9 @@ STATE_CLASS_NONE = ""
|
|||
# The state represents a measurement in present time
|
||||
STATE_CLASS_MEASUREMENT = "measurement"
|
||||
|
||||
# The state represents a total that only increases, a decrease is considered a reset.
|
||||
STATE_CLASS_TOTAL_INCREASING = "total_increasing"
|
||||
|
||||
# This sensor does not support resetting. ie, it is not accumulative
|
||||
LAST_RESET_TYPE_NONE = ""
|
||||
# This sensor is expected to never reset its value
|
||||
|
|
Loading…
Reference in a new issue