1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-03 16:41:50 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
Jesse Hills
b5b4047241 Use err from getting chunk length 2024-06-21 15:42:37 +12:00
Keith Burzinski
ddd5e345ac Int stuff 2024-06-20 22:18:37 -05:00
Jesse Hills
c354afda17 [http_request] Get chunked content length and add some logs 2024-06-21 14:33:10 +12:00
15 changed files with 33 additions and 60 deletions

View File

@@ -46,7 +46,7 @@ runs:
- name: Build and push to ghcr by digest
id: build-ghcr
uses: docker/build-push-action@v6.1.0
uses: docker/build-push-action@v6.0.1
with:
context: .
file: ./docker/Dockerfile
@@ -69,7 +69,7 @@ runs:
- name: Build and push to dockerhub by digest
id: build-dockerhub
uses: docker/build-push-action@v6.1.0
uses: docker/build-push-action@v6.0.1
with:
context: .
file: ./docker/Dockerfile

View File

@@ -9,10 +9,6 @@ static const char *const TAG = "gpio.one_wire";
void GPIOOneWireBus::setup() {
ESP_LOGCONFIG(TAG, "Setting up 1-wire bus...");
this->t_pin_->setup();
// clear bus with 480µs high, otherwise initial reset in search might fail
this->t_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
delayMicroseconds(480);
this->search();
}

View File

@@ -86,11 +86,13 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
return nullptr;
}
ESP_LOGV(TAG, "HTTP Request started: %s", url.c_str());
if (body_len > 0) {
int write_left = body_len;
int write_index = 0;
const char *buf = body.c_str();
while (write_left > 0) {
while (body_len > 0) {
int written = esp_http_client_write(client, buf + write_index, write_left);
if (written < 0) {
err = ESP_FAIL;
@@ -108,10 +110,26 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
return nullptr;
}
ESP_LOGV(TAG, "HTTP Request body written: %d", body_len);
container->content_length = esp_http_client_fetch_headers(client);
if (esp_http_client_is_chunked_response(client)) {
ESP_LOGV(TAG, "HTTP Response is chunked");
int length = 0;
err = esp_http_client_get_chunk_length(client, &length);
if (err != ESP_OK) {
this->status_momentary_error("failed", 1000);
ESP_LOGE(TAG, "Failed to get chunk length: %s", esp_err_to_name(err));
esp_http_client_cleanup(client);
return nullptr;
}
container->content_length = length;
}
const auto status_code = esp_http_client_get_status_code(client);
container->status_code = status_code;
ESP_LOGD(TAG, "Status %d", status_code);
if (status_code < 200 || status_code >= 300) {
ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url.c_str(), status_code);
this->status_momentary_error("failed", 1000);
@@ -147,6 +165,8 @@ void HttpContainerIDF::end() {
esp_http_client_close(this->client_);
esp_http_client_cleanup(this->client_);
ESP_LOGV(TAG, "HTTP Request ended: %d", this->status_code);
}
} // namespace http_request

View File

@@ -46,7 +46,7 @@ void WatchdogManager::set_timeout_(uint32_t timeout_ms) {
};
esp_task_wdt_reconfigure(&wdt_config);
#else
esp_task_wdt_init(timeout_ms / 1000, true);
esp_task_wdt_init(timeout_ms, true);
#endif // ESP_IDF_VERSION_MAJOR
#endif // USE_ESP32

View File

@@ -26,7 +26,6 @@ from esphome.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CARBON_DIOXIDE,
DEVICE_CLASS_CARBON_MONOXIDE,
DEVICE_CLASS_CONDUCTIVITY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_DATA_RATE,
DEVICE_CLASS_DATA_SIZE,
@@ -83,7 +82,6 @@ DEVICE_CLASSES = [
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CARBON_DIOXIDE,
DEVICE_CLASS_CARBON_MONOXIDE,
DEVICE_CLASS_CONDUCTIVITY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_DATA_RATE,
DEVICE_CLASS_DATA_SIZE,

View File

@@ -25,9 +25,6 @@ void QspiAmoLed::setup() {
}
void QspiAmoLed::update() {
if (!this->setup_complete_) {
return;
}
this->do_update_();
// Start addresses and widths/heights must be divisible by 2 (CASET/RASET restriction in datasheet)
if (this->x_low_ % 2 == 1) {

View File

@@ -65,10 +65,13 @@ class QspiAmoLed : public display::DisplayBuffer,
void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
void set_enable_pin(GPIOPin *enable_pin) { this->enable_pin_ = enable_pin; }
void set_width(uint16_t width) { this->width_ = width; }
void set_dimensions(uint16_t width, uint16_t height) {
this->width_ = width;
this->height_ = height;
}
int get_width() override { return this->width_; }
int get_height() override { return this->height_; }
void set_invert_colors(bool invert_colors) {
this->invert_colors_ = invert_colors;
this->reset_params_();

View File

@@ -88,7 +88,7 @@ def validate_parameter_name(value):
raise cv.Invalid(f"Script's parameter name cannot be {CONF_ID}")
ALLOWED_PARAM_TYPE_CHARSET = set("abcdefghijklmnopqrstuvwxyz0123456789_:*&[]<>")
ALLOWED_PARAM_TYPE_CHARSET = set("abcdefghijklmnopqrstuvwxyz0123456789_:*&[]")
def validate_parameter_type(value):

View File

@@ -2,7 +2,7 @@ import subprocess
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import display, key_provider
from esphome.components import display
from esphome.const import (
CONF_ID,
CONF_DIMENSIONS,
@@ -12,10 +12,8 @@ from esphome.const import (
PLATFORM_HOST,
)
AUTO_LOAD = ["key_provider"]
sdl_ns = cg.esphome_ns.namespace("sdl")
Sdl = sdl_ns.class_("Sdl", display.Display, key_provider.KeyProvider)
Sdl = sdl_ns.class_("Sdl", display.Display, cg.Component)
CONF_SDL_OPTIONS = "sdl_options"

View File

@@ -84,10 +84,6 @@ void Sdl::loop() {
}
break;
case SDL_KEYUP:
this->send_key_(e.key.keysym.sym);
break;
default:
ESP_LOGV(TAG, "Event %d", e.type);
break;

View File

@@ -1,11 +1,10 @@
#pragma once
#ifdef USE_HOST
#include "esphome/components/display/display.h"
#include "esphome/components/key_provider/key_provider.h"
#include "esphome/core/application.h"
#include "esphome/core/component.h"
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "esphome/components/display/display.h"
#define SDL_MAIN_HANDLED
#include "SDL.h"
@@ -14,7 +13,7 @@ namespace sdl {
constexpr static const char *const TAG = "sdl";
class Sdl : public display::Display, public key_provider::KeyProvider {
class Sdl : public display::Display {
public:
display::DisplayType get_display_type() override { return display::DISPLAY_TYPE_COLOR; }
void update() override;

View File

@@ -43,7 +43,6 @@ from esphome.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CARBON_DIOXIDE,
DEVICE_CLASS_CARBON_MONOXIDE,
DEVICE_CLASS_CONDUCTIVITY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_DATA_RATE,
DEVICE_CLASS_DATA_SIZE,
@@ -104,7 +103,6 @@ DEVICE_CLASSES = [
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CARBON_DIOXIDE,
DEVICE_CLASS_CARBON_MONOXIDE,
DEVICE_CLASS_CONDUCTIVITY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_DATA_RATE,
DEVICE_CLASS_DATA_SIZE,

View File

@@ -4,13 +4,11 @@ import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.const import (
CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY,
CONF_ID,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID,
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_FIRMWARE,
ENTITY_CATEGORY_CONFIG,
)
from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
@@ -43,9 +41,6 @@ UPDATE_SCHEMA = (
cv.Optional(CONF_ON_UPDATE_AVAILABLE): automation.validate_automation(
single=True
),
cv.Optional(
CONF_ENTITY_CATEGORY, default=ENTITY_CATEGORY_CONFIG
): cv.entity_category,
}
)
)

View File

@@ -1,35 +1,9 @@
#include "update_entity.h"
#include "esphome/core/log.h"
namespace esphome {
namespace update {
static const char *const TAG = "update";
void UpdateEntity::publish_state() {
ESP_LOGD(TAG, "'%s' - Publishing:", this->name_.c_str());
ESP_LOGD(TAG, " Current Version: %s", this->update_info_.current_version.c_str());
if (!this->update_info_.md5.empty()) {
ESP_LOGD(TAG, " Latest Version: %s", this->update_info_.latest_version.c_str());
}
if (!this->update_info_.firmware_url.empty()) {
ESP_LOGD(TAG, " Firmware URL: %s", this->update_info_.firmware_url.c_str());
}
ESP_LOGD(TAG, " Title: %s", this->update_info_.title.c_str());
if (!this->update_info_.summary.empty()) {
ESP_LOGD(TAG, " Summary: %s", this->update_info_.summary.c_str());
}
if (!this->update_info_.release_url.empty()) {
ESP_LOGD(TAG, " Release URL: %s", this->update_info_.release_url.c_str());
}
if (this->update_info_.has_progress) {
ESP_LOGD(TAG, " Progress: %.0f%%", this->update_info_.progress);
}
this->has_state_ = true;
this->state_callback_.call();
}

View File

@@ -1070,7 +1070,6 @@ DEVICE_CLASS_BUTTON = "button"
DEVICE_CLASS_CARBON_DIOXIDE = "carbon_dioxide"
DEVICE_CLASS_CARBON_MONOXIDE = "carbon_monoxide"
DEVICE_CLASS_COLD = "cold"
DEVICE_CLASS_CONDUCTIVITY = "conductivity"
DEVICE_CLASS_CONNECTIVITY = "connectivity"
DEVICE_CLASS_CURRENT = "current"
DEVICE_CLASS_CURTAIN = "curtain"