mirror of
https://github.com/esphome/esphome.git
synced 2024-12-21 16:27:44 +01:00
commit
ef87a6657a
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@ -315,7 +315,9 @@ jobs:
|
||||
key: platformio-${{ matrix.pio_cache_key }}
|
||||
|
||||
- name: Install clang-tidy
|
||||
run: sudo apt-get install clang-tidy-14
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install clang-tidy-14
|
||||
|
||||
- name: Register problem matchers
|
||||
run: |
|
||||
@ -397,7 +399,9 @@ jobs:
|
||||
file: ${{ fromJson(needs.list-components.outputs.components) }}
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get install libsdl2-dev
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install libsdl2-dev
|
||||
|
||||
- name: Check out code from GitHub
|
||||
uses: actions/checkout@v4.1.7
|
||||
@ -451,7 +455,9 @@ jobs:
|
||||
run: echo ${{ matrix.components }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get install libsdl2-dev
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install libsdl2-dev
|
||||
|
||||
- name: Check out code from GitHub
|
||||
uses: actions/checkout@v4.1.7
|
||||
|
@ -244,7 +244,7 @@ void CSE7766Component::dump_config() {
|
||||
LOG_SENSOR(" ", "Apparent Power", this->apparent_power_sensor_);
|
||||
LOG_SENSOR(" ", "Reactive Power", this->reactive_power_sensor_);
|
||||
LOG_SENSOR(" ", "Power Factor", this->power_factor_sensor_);
|
||||
this->check_uart_settings(4800);
|
||||
this->check_uart_settings(4800, 1, uart::UART_CONFIG_PARITY_EVEN);
|
||||
}
|
||||
|
||||
} // namespace cse7766
|
||||
|
@ -1,6 +1,6 @@
|
||||
from esphome import automation
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import mqtt
|
||||
from esphome.components import mqtt, web_server
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_DEVICE_CLASS,
|
||||
@ -11,6 +11,7 @@ from esphome.const import (
|
||||
CONF_MQTT_ID,
|
||||
CONF_ON_EVENT,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_WEB_SERVER,
|
||||
DEVICE_CLASS_BUTTON,
|
||||
DEVICE_CLASS_DOORBELL,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
@ -40,17 +41,21 @@ EventTrigger = event_ns.class_("EventTrigger", automation.Trigger.template())
|
||||
|
||||
validate_device_class = cv.one_of(*DEVICE_CLASSES, lower=True, space="_")
|
||||
|
||||
EVENT_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(cv.MQTT_COMPONENT_SCHEMA).extend(
|
||||
{
|
||||
cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id(mqtt.MQTTEventComponent),
|
||||
cv.GenerateID(): cv.declare_id(Event),
|
||||
cv.Optional(CONF_DEVICE_CLASS): validate_device_class,
|
||||
cv.Optional(CONF_ON_EVENT): automation.validate_automation(
|
||||
{
|
||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(EventTrigger),
|
||||
}
|
||||
),
|
||||
}
|
||||
EVENT_SCHEMA = (
|
||||
cv.ENTITY_BASE_SCHEMA.extend(web_server.WEBSERVER_SORTING_SCHEMA)
|
||||
.extend(cv.MQTT_COMPONENT_SCHEMA)
|
||||
.extend(
|
||||
{
|
||||
cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id(mqtt.MQTTEventComponent),
|
||||
cv.GenerateID(): cv.declare_id(Event),
|
||||
cv.Optional(CONF_DEVICE_CLASS): validate_device_class,
|
||||
cv.Optional(CONF_ON_EVENT): automation.validate_automation(
|
||||
{
|
||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(EventTrigger),
|
||||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
_UNDEF = object()
|
||||
@ -97,6 +102,9 @@ async def setup_event_core_(var, config, *, event_types: list[str]):
|
||||
mqtt_ = cg.new_Pvariable(mqtt_id, var)
|
||||
await mqtt.register_mqtt_component(mqtt_, config)
|
||||
|
||||
if web_server_config := config.get(CONF_WEB_SERVER):
|
||||
await web_server.add_entity_config(var, web_server_config)
|
||||
|
||||
|
||||
async def register_event(var, config, *, event_types: list[str]):
|
||||
if not CORE.has_id(config[CONF_ID]):
|
||||
|
@ -64,46 +64,46 @@ uint16_t shelly_dimmer_checksum(const uint8_t *buf, int len) {
|
||||
return std::accumulate<decltype(buf), uint16_t>(buf, buf + len, 0);
|
||||
}
|
||||
|
||||
bool ShellyDimmer::is_running_configured_version() const {
|
||||
return this->version_major_ == USE_SHD_FIRMWARE_MAJOR_VERSION &&
|
||||
this->version_minor_ == USE_SHD_FIRMWARE_MINOR_VERSION;
|
||||
}
|
||||
|
||||
void ShellyDimmer::handle_firmware() {
|
||||
// Reset the STM32 and check the firmware version.
|
||||
this->reset_normal_boot_();
|
||||
this->send_command_(SHELLY_DIMMER_PROTO_CMD_VERSION, nullptr, 0);
|
||||
ESP_LOGI(TAG, "STM32 current firmware version: %d.%d, desired version: %d.%d", this->version_major_,
|
||||
this->version_minor_, USE_SHD_FIRMWARE_MAJOR_VERSION, USE_SHD_FIRMWARE_MINOR_VERSION);
|
||||
|
||||
if (!is_running_configured_version()) {
|
||||
#ifdef USE_SHD_FIRMWARE_DATA
|
||||
if (!this->upgrade_firmware_()) {
|
||||
ESP_LOGW(TAG, "Failed to upgrade firmware");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
this->reset_normal_boot_();
|
||||
this->send_command_(SHELLY_DIMMER_PROTO_CMD_VERSION, nullptr, 0);
|
||||
if (!is_running_configured_version()) {
|
||||
ESP_LOGE(TAG, "STM32 firmware upgrade already performed, but version is still incorrect");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
#else
|
||||
ESP_LOGW(TAG, "Firmware version mismatch, put 'update: true' in the yaml to flash an update.");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void ShellyDimmer::setup() {
|
||||
this->pin_nrst_->setup();
|
||||
this->pin_boot0_->setup();
|
||||
|
||||
ESP_LOGI(TAG, "Initializing Shelly Dimmer...");
|
||||
|
||||
// Reset the STM32 and check the firmware version.
|
||||
for (int i = 0; i < 2; i++) {
|
||||
this->reset_normal_boot_();
|
||||
this->send_command_(SHELLY_DIMMER_PROTO_CMD_VERSION, nullptr, 0);
|
||||
ESP_LOGI(TAG, "STM32 current firmware version: %d.%d, desired version: %d.%d", this->version_major_,
|
||||
this->version_minor_, USE_SHD_FIRMWARE_MAJOR_VERSION, USE_SHD_FIRMWARE_MINOR_VERSION);
|
||||
if (this->version_major_ != USE_SHD_FIRMWARE_MAJOR_VERSION ||
|
||||
this->version_minor_ != USE_SHD_FIRMWARE_MINOR_VERSION) {
|
||||
#ifdef USE_SHD_FIRMWARE_DATA
|
||||
// Update firmware if needed.
|
||||
ESP_LOGW(TAG, "Unsupported STM32 firmware version, flashing");
|
||||
if (i > 0) {
|
||||
// Upgrade was already performed but the reported version is still not right.
|
||||
ESP_LOGE(TAG, "STM32 firmware upgrade already performed, but version is still incorrect");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->upgrade_firmware_()) {
|
||||
ESP_LOGW(TAG, "Failed to upgrade firmware");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
// Firmware upgrade completed, do the checks again.
|
||||
continue;
|
||||
#else
|
||||
ESP_LOGW(TAG, "Firmware version mismatch, put 'update: true' in the yaml to flash an update.");
|
||||
this->mark_failed();
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
this->handle_firmware();
|
||||
|
||||
this->send_settings_();
|
||||
// Do an immediate poll to refresh current state.
|
||||
|
@ -20,6 +20,8 @@ class ShellyDimmer : public PollingComponent, public light::LightOutput, public
|
||||
public:
|
||||
float get_setup_priority() const override { return setup_priority::LATE; }
|
||||
|
||||
bool is_running_configured_version() const;
|
||||
void handle_firmware();
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
|
@ -18,8 +18,8 @@ void Touchscreen::attach_interrupt_(InternalGPIOPin *irq_pin, esphome::gpio::Int
|
||||
|
||||
void Touchscreen::call_setup() {
|
||||
if (this->display_ != nullptr) {
|
||||
this->display_width_ = this->display_->get_native_width();
|
||||
this->display_height_ = this->display_->get_native_height();
|
||||
this->display_width_ = this->display_->get_width();
|
||||
this->display_height_ = this->display_->get_height();
|
||||
}
|
||||
PollingComponent::call_setup();
|
||||
}
|
||||
|
@ -1443,7 +1443,7 @@ void WebServer::on_event(event::Event *obj, const std::string &event_type) {
|
||||
}
|
||||
|
||||
std::string WebServer::event_json(event::Event *obj, const std::string &event_type, JsonDetail start_config) {
|
||||
return json::build_json([obj, event_type, start_config](JsonObject root) {
|
||||
return json::build_json([this, obj, event_type, start_config](JsonObject root) {
|
||||
set_json_id(root, obj, "event-" + obj->get_object_id(), start_config);
|
||||
if (!event_type.empty()) {
|
||||
root["event_type"] = event_type;
|
||||
@ -1454,6 +1454,12 @@ std::string WebServer::event_json(event::Event *obj, const std::string &event_ty
|
||||
event_types.add(event_type);
|
||||
}
|
||||
root["device_class"] = obj->get_device_class();
|
||||
if (this->sorting_entitys_.find(obj) != this->sorting_entitys_.end()) {
|
||||
root["sorting_weight"] = this->sorting_entitys_[obj].weight;
|
||||
if (this->sorting_groups_.find(this->sorting_entitys_[obj].group_id) != this->sorting_groups_.end()) {
|
||||
root["sorting_group"] = this->sorting_groups_[this->sorting_entitys_[obj].group_id].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2024.10.0b1"
|
||||
__version__ = "2024.10.0b2"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
|
Loading…
Reference in New Issue
Block a user