15 HTTP_CODE_NOT_MODIFIED = 304,
16 HTTP_CODE_NOT_FOUND = 404,
26 public Parented<esphome::http_request::HttpRequestComponent> {
43 bool is_big_endian =
false);
78 std::shared_ptr<http_request::HttpContainer>
downloader_{
nullptr};
108 void
play(const Ts &...
x)
override {
110 if (this->update_.value(
x...)) {
111 this->parent_->update();
Helper class to easily give an object a parent of type T.
This class simplifies creating components that periodically check a state.
void trigger(const Ts &...x)
Buffer for managing downloaded data.
DownloadErrorTrigger(OnlineImage *parent)
DownloadFinishedTrigger(OnlineImage *parent)
Download an image from a given URL, and decode it using the specified decoder.
std::string etag_
The value of the ETag HTTP header provided in the last response.
OnlineImage(const std::string &url, int width, int height, runtime_image::ImageFormat format, image::ImageType type, image::Transparency transparency, image::Image *placeholder, uint32_t buffer_size, bool is_big_endian=false)
Construct a new OnlineImage object.
bool validate_url_(const std::string &url)
CallbackManager< void(bool)> download_finished_callback_
std::vector< std::pair< std::string, TemplatableValue< std::string > > > request_headers_
void add_on_error_callback(std::function< void()> &&callback)
void add_request_header(const std::string &header, V value)
Add the request header.
void add_on_finished_callback(std::function< void(bool)> &&callback)
DownloadBuffer download_buffer_
void set_url(const std::string &url)
Set the URL to download the image from.
std::shared_ptr< http_request::HttpContainer > downloader_
CallbackManager< void()> download_error_callback_
size_t download_buffer_initial_size_
This is the initial size of the download buffer, not the current size.
std::string last_modified_
The value of the Last-Modified HTTP header provided in the last response.
void release()
Release the buffer storing the image.
void play(const Ts &...x) override
OnlineImageReleaseAction(OnlineImage *parent)
OnlineImageSetUrlAction(OnlineImage *parent)
update void play(const Ts &...x) override
TEMPLATABLE_VALUE(std::string, url) TEMPLATABLE_VALUE(bool
A dynamic image that can be loaded and decoded at runtime.
enum { HTTP_CODE_OK=200, HTTP_CODE_NOT_MODIFIED=304, HTTP_CODE_NOT_FOUND=404, } t_http_codes
ImageFormat
Image format types that can be decoded dynamically.