Merge remote-tracking branch 'upstream/dev' into gsm

This commit is contained in:
oarcher 2024-08-13 23:30:02 +02:00
commit 412ba4f60f
64 changed files with 668 additions and 58 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.6.1
uses: docker/build-push-action@v6.7.0
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.6.1
uses: docker/build-push-action@v6.7.0
with:
context: .
file: ./docker/Dockerfile

View file

@ -9,6 +9,7 @@ on:
paths:
- "**"
- "!.github/workflows/*.yml"
- "!.github/actions/build-image/*"
- ".github/workflows/ci.yml"
- "!.yamllint"
- "!.github/dependabot.yml"

View file

@ -168,7 +168,7 @@ esphome/components/he60r/* @clydebarrow
esphome/components/heatpumpir/* @rob-deutsch
esphome/components/hitachi_ac424/* @sourabhjaiswal
esphome/components/hm3301/* @freekode
esphome/components/homeassistant/* @OttoWinter
esphome/components/homeassistant/* @OttoWinter @esphome/core
esphome/components/honeywell_hih_i2c/* @Benichou34
esphome/components/honeywellabp/* @RubyBailey
esphome/components/honeywellabp2_i2c/* @jpfaff
@ -457,6 +457,7 @@ esphome/components/wl_134/* @hobbypunk90
esphome/components/x9c/* @EtienneMD
esphome/components/xgzp68xx/* @gcormier
esphome/components/xiaomi_hhccjcy10/* @fariouche
esphome/components/xiaomi_lywsd02mmc/* @juanluss31
esphome/components/xiaomi_lywsd03mmc/* @ahpohl
esphome/components/xiaomi_mhoc303/* @drug123
esphome/components/xiaomi_mhoc401/* @vevsvevs

View file

@ -686,6 +686,7 @@ message SubscribeHomeAssistantStateResponse {
option (source) = SOURCE_SERVER;
string entity_id = 1;
string attribute = 2;
bool once = 3;
}
message HomeAssistantStateResponse {

View file

@ -1335,6 +1335,9 @@ void APIConnection::update_command(const UpdateCommandRequest &msg) {
case enums::UPDATE_COMMAND_CHECK:
update->check();
break;
case enums::UPDATE_COMMAND_NONE:
ESP_LOGE(TAG, "UPDATE_COMMAND_NONE not handled. Check client is sending the correct command");
break;
default:
ESP_LOGW(TAG, "Unknown update command: %" PRIu32, msg.command);
break;

View file

@ -3109,6 +3109,16 @@ void SubscribeHomeAssistantStatesRequest::dump_to(std::string &out) const {
out.append("SubscribeHomeAssistantStatesRequest {}");
}
#endif
bool SubscribeHomeAssistantStateResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
switch (field_id) {
case 3: {
this->once = value.as_bool();
return true;
}
default:
return false;
}
}
bool SubscribeHomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
switch (field_id) {
case 1: {
@ -3126,6 +3136,7 @@ bool SubscribeHomeAssistantStateResponse::decode_length(uint32_t field_id, Proto
void SubscribeHomeAssistantStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_string(1, this->entity_id);
buffer.encode_string(2, this->attribute);
buffer.encode_bool(3, this->once);
}
#ifdef HAS_PROTO_MESSAGE_DUMP
void SubscribeHomeAssistantStateResponse::dump_to(std::string &out) const {
@ -3138,6 +3149,10 @@ void SubscribeHomeAssistantStateResponse::dump_to(std::string &out) const {
out.append(" attribute: ");
out.append("'").append(this->attribute).append("'");
out.append("\n");
out.append(" once: ");
out.append(YESNO(this->once));
out.append("\n");
out.append("}");
}
#endif

View file

@ -836,6 +836,7 @@ class SubscribeHomeAssistantStateResponse : public ProtoMessage {
public:
std::string entity_id{};
std::string attribute{};
bool once{false};
void encode(ProtoWriteBuffer buffer) const override;
#ifdef HAS_PROTO_MESSAGE_DUMP
void dump_to(std::string &out) const override;
@ -843,6 +844,7 @@ class SubscribeHomeAssistantStateResponse : public ProtoMessage {
protected:
bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override;
bool decode_varint(uint32_t field_id, ProtoVarInt value) override;
};
class HomeAssistantStateResponse : public ProtoMessage {
public:

View file

@ -359,8 +359,18 @@ void APIServer::subscribe_home_assistant_state(std::string entity_id, optional<s
.entity_id = std::move(entity_id),
.attribute = std::move(attribute),
.callback = std::move(f),
.once = false,
});
}
void APIServer::get_home_assistant_state(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f) {
this->state_subs_.push_back(HomeAssistantStateSubscription{
.entity_id = std::move(entity_id),
.attribute = std::move(attribute),
.callback = std::move(f),
.once = true,
});
};
const std::vector<APIServer::HomeAssistantStateSubscription> &APIServer::get_state_subs() const {
return this->state_subs_;
}

View file

@ -112,10 +112,13 @@ class APIServer : public Component, public Controller {
std::string entity_id;
optional<std::string> attribute;
std::function<void(std::string)> callback;
bool once;
};
void subscribe_home_assistant_state(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f);
void get_home_assistant_state(std::string entity_id, optional<std::string> attribute,
std::function<void(std::string)> f);
const std::vector<HomeAssistantStateSubscription> &get_state_subs() const;
const std::vector<UserServiceDescriptor *> &get_user_services() const { return this->user_services_; }

View file

@ -90,7 +90,7 @@ struct BedjetStatusPacket {
int unused_6 : 1; // 0x4
bool is_dual_zone : 1; /// Is part of a Dual Zone configuration
int unused_7 : 1; // 0x1
} dual_zone_flags;
} dual_zone_flags; // NOLINT(clang-diagnostic-unaligned-access)
uint8_t unused_4 : 8; // Unknown 23-24 = 0x1310
uint8_t unused_5 : 8; // Unknown 23-24 = 0x1310

View file

@ -307,7 +307,7 @@ void FingerprintGrowComponent::delete_fingerprint(uint16_t finger_id) {
void FingerprintGrowComponent::delete_all_fingerprints() {
ESP_LOGI(TAG, "Deleting all stored fingerprints");
this->data_ = {EMPTY};
this->data_ = {DELETE_ALL};
switch (this->send_command_()) {
case OK:
ESP_LOGI(TAG, "Deleted all fingerprints");

View file

@ -36,7 +36,7 @@ enum GrowCommand {
LOAD = 0x07,
UPLOAD = 0x08,
DELETE = 0x0C,
EMPTY = 0x0D,
DELETE_ALL = 0x0D, // aka EMPTY
READ_SYS_PARAM = 0x0F,
SET_PASSWORD = 0x12,
VERIFY_PASSWORD = 0x13,

View file

@ -80,8 +80,8 @@ class HaierClimateBase : public esphome::Component,
const char *phase_to_string_(ProtocolPhases phase);
virtual void set_handlers() = 0;
virtual void process_phase(std::chrono::steady_clock::time_point now) = 0;
virtual haier_protocol::HaierMessage get_control_message() = 0;
virtual haier_protocol::HaierMessage get_power_message(bool state) = 0;
virtual haier_protocol::HaierMessage get_control_message() = 0; // NOLINT(readability-identifier-naming)
virtual haier_protocol::HaierMessage get_power_message(bool state) = 0; // NOLINT(readability-identifier-naming)
virtual void initialization(){};
virtual bool prepare_pending_action();
virtual void process_protocol_reset();

View file

@ -2,7 +2,7 @@ import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.const import CONF_ATTRIBUTE, CONF_ENTITY_ID, CONF_INTERNAL
CODEOWNERS = ["@OttoWinter"]
CODEOWNERS = ["@OttoWinter", "@esphome/core"]
homeassistant_ns = cg.esphome_ns.namespace("homeassistant")
HOME_ASSISTANT_IMPORT_SCHEMA = cv.Schema(
@ -13,6 +13,13 @@ HOME_ASSISTANT_IMPORT_SCHEMA = cv.Schema(
}
)
HOME_ASSISTANT_IMPORT_CONTROL_SCHEMA = cv.Schema(
{
cv.Required(CONF_ENTITY_ID): cv.entity_id,
cv.Optional(CONF_INTERNAL, default=True): cv.boolean,
}
)
def setup_home_assistant_entity(var, config):
cg.add(var.set_entity_id(config[CONF_ENTITY_ID]))

View file

@ -25,7 +25,7 @@ class PulseLightEffect : public LightEffect {
return;
}
auto call = this->state_->turn_on();
float out = this->on_ ? this->max_brightness : this->min_brightness;
float out = this->on_ ? this->max_brightness_ : this->min_brightness_;
call.set_brightness_if_supported(out);
call.set_transition_length_if_supported(this->on_ ? this->transition_on_length_ : this->transition_off_length_);
this->on_ = !this->on_;
@ -43,8 +43,8 @@ class PulseLightEffect : public LightEffect {
void set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; }
void set_min_max_brightness(float min, float max) {
this->min_brightness = min;
this->max_brightness = max;
this->min_brightness_ = min;
this->max_brightness_ = max;
}
protected:
@ -53,8 +53,8 @@ class PulseLightEffect : public LightEffect {
uint32_t transition_on_length_{};
uint32_t transition_off_length_{};
uint32_t update_interval_{};
float min_brightness{0.0};
float max_brightness{1.0};
float min_brightness_{0.0};
float max_brightness_{1.0};
};
/// Random effect. Sets random colors every 10 seconds and slowly transitions between them.

View file

@ -23,7 +23,7 @@ from esphome.helpers import write_file_if_changed
from . import defines as df, helpers, lv_validation as lvalid
from .automation import disp_update, update_to_code
from .defines import CONF_SKIP
from .encoders import ENCODERS_CONFIG, encoders_to_code
from .encoders import ENCODERS_CONFIG, encoders_to_code, initial_focus_to_code
from .lv_validation import lv_bool, lv_images_used
from .lvcode import LvContext, LvglComponent
from .schemas import (
@ -272,6 +272,7 @@ async def to_code(config):
templ = await cg.templatable(conf[CONF_TIMEOUT], [], cg.uint32)
idle_trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], lv_component, templ)
await build_automation(idle_trigger, [], conf)
await initial_focus_to_code(config)
for comp in helpers.lvgl_components_required:
CORE.add_define(f"USE_LVGL_{comp.upper()}")

View file

@ -413,6 +413,7 @@ CONF_GRID_ROW_ALIGN = "grid_row_align"
CONF_GRID_ROWS = "grid_rows"
CONF_HEADER_MODE = "header_mode"
CONF_HOME = "home"
CONF_INITIAL_FOCUS = "initial_focus"
CONF_KEY_CODE = "key_code"
CONF_LAYOUT = "layout"
CONF_LEFT_BUTTON = "left_button"

View file

@ -8,6 +8,7 @@ from .defines import (
CONF_DEFAULT_GROUP,
CONF_ENCODERS,
CONF_ENTER_BUTTON,
CONF_INITIAL_FOCUS,
CONF_LEFT_BUTTON,
CONF_LONG_PRESS_REPEAT_TIME,
CONF_LONG_PRESS_TIME,
@ -67,3 +68,10 @@ async def encoders_to_code(var, config):
else:
group = default_group
lv.indev_set_group(lv_expr.indev_drv_register(listener.get_drv()), group)
async def initial_focus_to_code(config):
for enc_conf in config[CONF_ENCODERS]:
if default_focus := enc_conf.get(CONF_INITIAL_FOCUS):
obj = await cg.get_variable(default_focus)
lv.group_focus_obj(obj)

View file

@ -14,11 +14,19 @@ from esphome.const import (
from esphome.core import TimePeriod
from esphome.schema_extractors import SCHEMA_EXTRACT
from . import defines as df, lv_validation as lvalid, types as ty
from . import defines as df, lv_validation as lvalid
from .helpers import add_lv_use, requires_component, validate_printf
from .lv_validation import lv_color, lv_font, lv_image
from .lvcode import LvglComponent
from .types import WidgetType, lv_group_t
from .types import (
LVEncoderListener,
LvType,
WidgetType,
lv_group_t,
lv_obj_t,
lv_pseudo_button_t,
lv_style_t,
)
# this will be populated later, in __init__.py to avoid circular imports.
WIDGET_TYPES: dict = {}
@ -46,7 +54,7 @@ TEXT_SCHEMA = cv.Schema(
LIST_ACTION_SCHEMA = cv.ensure_list(
cv.maybe_simple_value(
{
cv.Required(CONF_ID): cv.use_id(ty.lv_pseudo_button_t),
cv.Required(CONF_ID): cv.use_id(lv_pseudo_button_t),
},
key=CONF_ID,
)
@ -59,9 +67,10 @@ PRESS_TIME = cv.All(
ENCODER_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.All(
cv.declare_id(ty.LVEncoderListener), requires_component("binary_sensor")
cv.declare_id(LVEncoderListener), requires_component("binary_sensor")
),
cv.Optional(CONF_GROUP): cv.declare_id(lv_group_t),
cv.Optional(df.CONF_INITIAL_FOCUS): cv.use_id(lv_obj_t),
cv.Optional(df.CONF_LONG_PRESS_TIME, default="400ms"): PRESS_TIME,
cv.Optional(df.CONF_LONG_PRESS_REPEAT_TIME, default="100ms"): PRESS_TIME,
}
@ -161,7 +170,7 @@ STYLE_REMAP = {
# Complete object style schema
STYLE_SCHEMA = cv.Schema({cv.Optional(k): v for k, v in STYLE_PROPS.items()}).extend(
{
cv.Optional(df.CONF_STYLES): cv.ensure_list(cv.use_id(ty.lv_style_t)),
cv.Optional(df.CONF_STYLES): cv.ensure_list(cv.use_id(lv_style_t)),
cv.Optional(df.CONF_SCROLLBAR_MODE): df.LvConstant(
"LV_SCROLLBAR_MODE_", "OFF", "ON", "ACTIVE", "AUTO"
).one_of,
@ -193,12 +202,12 @@ def part_schema(widget_type: WidgetType):
)
def automation_schema(typ: ty.LvType):
def automation_schema(typ: LvType):
if typ.has_on_value:
events = df.LV_EVENT_TRIGGERS + (CONF_ON_VALUE,)
else:
events = df.LV_EVENT_TRIGGERS
if isinstance(typ, ty.LvType):
if isinstance(typ, LvType):
template = Trigger.template(typ.get_arg_type())
else:
template = Trigger.template()
@ -261,7 +270,7 @@ LAYOUT_SCHEMAS = {}
ALIGN_TO_SCHEMA = {
cv.Optional(df.CONF_ALIGN_TO): cv.Schema(
{
cv.Required(CONF_ID): cv.use_id(ty.lv_obj_t),
cv.Required(CONF_ID): cv.use_id(lv_obj_t),
cv.Required(df.CONF_ALIGN): df.ALIGN_ALIGNMENTS.one_of,
cv.Optional(df.CONF_X, default=0): lvalid.pixels_or_percent,
cv.Optional(df.CONF_Y, default=0): lvalid.pixels_or_percent,

View file

@ -1,5 +1,6 @@
#pragma once
#include "esphome/core/defines.h"
#ifdef USE_MQTT
#include <string>
#include <map>
#include "esphome/components/network/ip_address.h"
@ -67,3 +68,4 @@ class MQTTBackend {
} // namespace mqtt
} // namespace esphome
#endif

View file

@ -1,7 +1,9 @@
#include "mqtt_backend_esp32.h"
#ifdef USE_MQTT
#ifdef USE_ESP32
#include <string>
#include "mqtt_backend_esp32.h"
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
@ -189,3 +191,4 @@ void MQTTBackendESP32::mqtt_event_handler(void *handler_args, esp_event_base_t b
} // namespace mqtt
} // namespace esphome
#endif // USE_ESP32
#endif

View file

@ -1,5 +1,7 @@
#pragma once
#include "mqtt_backend.h"
#ifdef USE_MQTT
#ifdef USE_ESP32
#include <string>
@ -7,7 +9,6 @@
#include <mqtt_client.h>
#include "esphome/components/network/ip_address.h"
#include "esphome/core/helpers.h"
#include "mqtt_backend.h"
namespace esphome {
namespace mqtt {
@ -174,3 +175,4 @@ class MQTTBackendESP32 final : public MQTTBackend {
} // namespace esphome
#endif
#endif

View file

@ -1,8 +1,9 @@
#pragma once
#include "mqtt_backend.h"
#ifdef USE_MQTT
#ifdef USE_ESP8266
#include "mqtt_backend.h"
#include <AsyncMqttClient.h>
namespace esphome {
@ -70,3 +71,4 @@ class MQTTBackendESP8266 final : public MQTTBackend {
} // namespace esphome
#endif // defined(USE_ESP8266)
#endif

View file

@ -1,8 +1,9 @@
#pragma once
#include "mqtt_backend.h"
#ifdef USE_MQTT
#ifdef USE_LIBRETINY
#include "mqtt_backend.h"
#include <AsyncMqttClient.h>
namespace esphome {
@ -70,3 +71,4 @@ class MQTTBackendLibreTiny final : public MQTTBackend {
} // namespace esphome
#endif // defined(USE_LIBRETINY)
#endif

View file

@ -1,8 +1,6 @@
from esphome.core import CORE
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components.esp32 import add_idf_sdkconfig_option
import esphome.config_validation as cv
from esphome.const import (
CONF_ENABLE_IPV6,
CONF_MIN_IPV6_ADDR_COUNT,
@ -10,6 +8,7 @@ from esphome.const import (
PLATFORM_ESP8266,
PLATFORM_RP2040,
)
from esphome.core import CORE
CODEOWNERS = ["@esphome/core"]
AUTO_LOAD = ["mdns"]
@ -33,6 +32,7 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config):
cg.add_define("USE_NETWORK")
if (enable_ipv6 := config.get(CONF_ENABLE_IPV6, None)) is not None:
cg.add_define("USE_NETWORK_IPV6", enable_ipv6)
if enable_ipv6:
@ -42,8 +42,7 @@ async def to_code(config):
if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
else:
if enable_ipv6:
elif enable_ipv6:
cg.add_build_flag("-DCONFIG_LWIP_IPV6")
cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG")
if CORE.is_rp2040:

View file

@ -1,4 +1,6 @@
#pragma once
#include "esphome/core/defines.h"
#ifdef USE_NETWORK
#include <cstdint>
#include <string>
#include <cstdio>
@ -140,3 +142,4 @@ using IPAddresses = std::array<IPAddress, 5>;
} // namespace network
} // namespace esphome
#endif

View file

@ -1,6 +1,6 @@
#include "util.h"
#include "esphome/core/defines.h"
#ifdef USE_NETWORK
#ifdef USE_WIFI
#include "esphome/components/wifi/wifi_component.h"
#endif
@ -93,3 +93,4 @@ std::string get_use_address() {
} // namespace network
} // namespace esphome
#endif

View file

@ -1,5 +1,6 @@
#pragma once
#include "esphome/core/defines.h"
#ifdef USE_NETWORK
#include <string>
#include "ip_address.h"
@ -16,3 +17,4 @@ IPAddresses get_ip_addresses();
} // namespace network
} // namespace esphome
#endif

View file

@ -27,6 +27,7 @@ CODEOWNERS = ["@guillempages"]
MULTI_CONF = True
CONF_ON_DOWNLOAD_FINISHED = "on_download_finished"
CONF_PLACEHOLDER = "placeholder"
_LOGGER = logging.getLogger(__name__)
@ -73,6 +74,7 @@ ONLINE_IMAGE_SCHEMA = cv.Schema(
#
cv.Required(CONF_URL): cv.url,
cv.Required(CONF_FORMAT): cv.enum(IMAGE_FORMAT, upper=True),
cv.Optional(CONF_PLACEHOLDER): cv.use_id(Image_),
cv.Optional(CONF_BUFFER_SIZE, default=2048): cv.int_range(256, 65536),
cv.Optional(CONF_ON_DOWNLOAD_FINISHED): automation.validate_automation(
{
@ -152,6 +154,10 @@ async def to_code(config):
cg.add(var.set_transparency(transparent))
if placeholder_id := config.get(CONF_PLACEHOLDER):
placeholder = await cg.get_variable(placeholder_id)
cg.add(var.set_placeholder(placeholder))
for conf in config.get(CONF_ON_DOWNLOAD_FINISHED, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [], conf)

View file

@ -35,6 +35,14 @@ OnlineImage::OnlineImage(const std::string &url, int width, int height, ImageFor
this->set_url(url);
}
void OnlineImage::draw(int x, int y, display::Display *display, Color color_on, Color color_off) {
if (this->data_start_) {
Image::draw(x, y, display, color_on, color_off);
} else if (this->placeholder_) {
this->placeholder_->draw(x, y, display, color_on, color_off);
}
}
void OnlineImage::release() {
if (this->buffer_) {
ESP_LOGD(TAG, "Deallocating old buffer...");

View file

@ -50,6 +50,8 @@ class OnlineImage : public PollingComponent,
OnlineImage(const std::string &url, int width, int height, ImageFormat format, image::ImageType type,
uint32_t buffer_size);
void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override;
void update() override;
void loop() override;
@ -60,6 +62,14 @@ class OnlineImage : public PollingComponent,
}
}
/**
* @brief Set the image that needs to be shown as long as the downloaded image
* is not available.
*
* @param placeholder Pointer to the (@link Image) to show as placeholder.
*/
void set_placeholder(image::Image *placeholder) { this->placeholder_ = placeholder; }
/**
* Release the buffer storing the image. The image will need to be downloaded again
* to be able to be displayed.
@ -113,6 +123,7 @@ class OnlineImage : public PollingComponent,
DownloadBuffer download_buffer_;
const ImageFormat format_;
image::Image *placeholder_{nullptr};
std::string url_{""};

View file

@ -334,7 +334,7 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
/// Override the web handler's handleRequest method.
void handleRequest(AsyncWebServerRequest *request) override;
/// This web handle is not trivial.
bool isRequestHandlerTrivial() override;
bool isRequestHandlerTrivial() override; // NOLINT(readability-identifier-naming)
void add_entity_to_sorting_list(EntityBase *entity, float weight);

View file

@ -134,6 +134,7 @@ class OTARequestHandler : public AsyncWebHandler {
return request->url() == "/update" && request->method() == HTTP_POST;
}
// NOLINTNEXTLINE(readability-identifier-naming)
bool isRequestHandlerTrivial() override { return false; }
protected:

View file

@ -1,4 +1,5 @@
#include "wifi_component.h"
#ifdef USE_WIFI
#include <cinttypes>
#include <map>
@ -856,3 +857,4 @@ WiFiComponent *global_wifi_component; // NOLINT(cppcoreguidelines-avoid-non-con
} // namespace wifi
} // namespace esphome
#endif

View file

@ -1,9 +1,10 @@
#pragma once
#include "esphome/core/defines.h"
#ifdef USE_WIFI
#include "esphome/components/network/ip_address.h"
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
#include "esphome/core/defines.h"
#include "esphome/core/helpers.h"
#include <string>
@ -442,3 +443,4 @@ template<typename... Ts> class WiFiDisableAction : public Action<Ts...> {
} // namespace wifi
} // namespace esphome
#endif

View file

@ -1,5 +1,6 @@
#include "wifi_component.h"
#ifdef USE_WIFI
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
#include <esp_netif.h>
@ -802,3 +803,4 @@ network::IPAddress WiFiComponent::wifi_dns_ip_(int num) { return network::IPAddr
} // namespace esphome
#endif // USE_ESP32_FRAMEWORK_ARDUINO
#endif

View file

@ -1,6 +1,7 @@
#include "wifi_component.h"
#include "esphome/core/defines.h"
#ifdef USE_WIFI
#ifdef USE_ESP8266
#include <user_interface.h>
@ -834,3 +835,4 @@ void WiFiComponent::wifi_loop_() {}
} // namespace esphome
#endif
#endif

View file

@ -1,5 +1,6 @@
#include "wifi_component.h"
#ifdef USE_WIFI
#ifdef USE_ESP_IDF
#include <esp_event.h>
@ -1010,3 +1011,4 @@ network::IPAddress WiFiComponent::wifi_dns_ip_(int num) {
} // namespace esphome
#endif // USE_ESP_IDF
#endif

View file

@ -1,5 +1,6 @@
#include "wifi_component.h"
#ifdef USE_WIFI
#ifdef USE_LIBRETINY
#include <utility>
@ -468,3 +469,4 @@ void WiFiComponent::wifi_loop_() {}
} // namespace esphome
#endif // USE_LIBRETINY
#endif

View file

@ -1,6 +1,7 @@
#include "wifi_component.h"
#ifdef USE_WIFI
#ifdef USE_RP2040
#include "lwip/dns.h"
@ -218,3 +219,4 @@ void WiFiComponent::wifi_pre_setup_() {}
} // namespace esphome
#endif
#endif

View file

@ -1,4 +1,5 @@
#include "wifi_info_text_sensor.h"
#ifdef USE_WIFI
#include "esphome/core/log.h"
namespace esphome {
@ -15,3 +16,4 @@ void DNSAddressWifiInfo::dump_config() { LOG_TEXT_SENSOR("", "WifiInfo DNS Addre
} // namespace wifi_info
} // namespace esphome
#endif

View file

@ -3,6 +3,7 @@
#include "esphome/core/component.h"
#include "esphome/components/text_sensor/text_sensor.h"
#include "esphome/components/wifi/wifi_component.h"
#ifdef USE_WIFI
#include <array>
namespace esphome {
@ -131,3 +132,4 @@ class MacAddressWifiInfo : public Component, public text_sensor::TextSensor {
} // namespace wifi_info
} // namespace esphome
#endif

View file

@ -1,4 +1,5 @@
#include "wifi_signal_sensor.h"
#ifdef USE_WIFI
#include "esphome/core/log.h"
namespace esphome {
@ -10,3 +11,4 @@ void WiFiSignalSensor::dump_config() { LOG_SENSOR("", "WiFi Signal", this); }
} // namespace wifi_signal
} // namespace esphome
#endif

View file

@ -4,7 +4,7 @@
#include "esphome/core/helpers.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/wifi/wifi_component.h"
#ifdef USE_WIFI
namespace esphome {
namespace wifi_signal {
@ -19,3 +19,4 @@ class WiFiSignalSensor : public sensor::Sensor, public PollingComponent {
} // namespace wifi_signal
} // namespace esphome
#endif

View file

@ -49,8 +49,8 @@ bool parse_xiaomi_value(uint16_t value_type, const uint8_t *data, uint8_t value_
const uint16_t conductivity = encode_uint16(data[1], data[0]);
result.conductivity = conductivity;
}
// battery, 1 byte, 8-bit unsigned integer, 1 %
else if ((value_type == 0x100A) && (value_length == 1)) {
// battery / MiaoMiaoce battery, 1 byte, 8-bit unsigned integer, 1 %
else if ((value_type == 0x100A || value_type == 0x4803) && (value_length == 1)) {
result.battery_level = data[0];
}
// temperature + humidity, 4 bytes, 16-bit signed integer (LE) each, 0.1 °C, 0.1 %
@ -80,6 +80,17 @@ bool parse_xiaomi_value(uint16_t value_type, const uint8_t *data, uint8_t value_
result.has_motion = !idle_time;
} else if ((value_type == 0x1018) && (value_length == 1)) {
result.is_light = data[0];
}
// MiaoMiaoce temperature, 4 bytes, float, 0.1 °C
else if ((value_type == 0x4C01) && (value_length == 4)) {
const uint32_t int_number = encode_uint32(data[3], data[2], data[1], data[0]);
float temperature;
std::memcpy(&temperature, &int_number, sizeof(temperature));
result.temperature = temperature;
}
// MiaoMiaoce humidity, 1 byte, 8-bit unsigned integer, 1 %
else if ((value_type == 0x4C02) && (value_length == 1)) {
result.humidity = data[0];
} else {
return false;
}
@ -111,7 +122,8 @@ bool parse_xiaomi_message(const std::vector<uint8_t> &message, XiaomiParseResult
}
while (payload_length > 3) {
if (payload[payload_offset + 1] != 0x10 && payload[payload_offset + 1] != 0x00) {
if (payload[payload_offset + 1] != 0x10 && payload[payload_offset + 1] != 0x00 &&
payload[payload_offset + 1] != 0x4C && payload[payload_offset + 1] != 0x48) {
ESP_LOGVV(TAG, "parse_xiaomi_message(): fixed byte not found, stop parsing residual data.");
break;
}
@ -190,6 +202,11 @@ optional<XiaomiParseResult> parse_xiaomi_header(const esp32_ble_tracker::Service
} else if (device_uuid == 0x045b) { // rectangular body, e-ink display
result.type = XiaomiParseResult::TYPE_LYWSD02;
result.name = "LYWSD02";
} else if (device_uuid == 0x2542) { // rectangular body, e-ink display — with bindkeys
result.type = XiaomiParseResult::TYPE_LYWSD02MMC;
result.name = "LYWSD02MMC";
if (raw.size() == 19)
result.raw_offset -= 6;
} else if (device_uuid == 0x040a) { // Mosquito Repellent Smart Version
result.type = XiaomiParseResult::TYPE_WX08ZM;
result.name = "WX08ZM";

View file

@ -17,6 +17,7 @@ struct XiaomiParseResult {
TYPE_HHCCPOT002,
TYPE_LYWSDCGQ,
TYPE_LYWSD02,
TYPE_LYWSD02MMC,
TYPE_CGG1,
TYPE_LYWSD03MMC,
TYPE_CGD1,

View file

@ -0,0 +1,77 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import sensor, esp32_ble_tracker
from esphome.const import (
CONF_BATTERY_LEVEL,
CONF_HUMIDITY,
CONF_MAC_ADDRESS,
CONF_TEMPERATURE,
DEVICE_CLASS_TEMPERATURE,
ENTITY_CATEGORY_DIAGNOSTIC,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
UNIT_PERCENT,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_BATTERY,
CONF_ID,
CONF_BINDKEY,
)
AUTO_LOAD = ["xiaomi_ble"]
CODEOWNERS = ["@juanluss31"]
DEPENDENCIES = ["esp32_ble_tracker"]
xiaomi_lywsd02mmc_ns = cg.esphome_ns.namespace("xiaomi_lywsd02mmc")
XiaomiLYWSD02MMC = xiaomi_lywsd02mmc_ns.class_(
"XiaomiLYWSD02MMC", esp32_ble_tracker.ESPBTDeviceListener, cg.Component
)
CONFIG_SCHEMA = (
cv.Schema(
{
cv.GenerateID(): cv.declare_id(XiaomiLYWSD02MMC),
cv.Required(CONF_MAC_ADDRESS): cv.mac_address,
cv.Required(CONF_BINDKEY): cv.bind_key,
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
accuracy_decimals=1,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
),
cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
unit_of_measurement=UNIT_PERCENT,
accuracy_decimals=0,
device_class=DEVICE_CLASS_HUMIDITY,
state_class=STATE_CLASS_MEASUREMENT,
),
cv.Optional(CONF_BATTERY_LEVEL): sensor.sensor_schema(
unit_of_measurement=UNIT_PERCENT,
accuracy_decimals=0,
device_class=DEVICE_CLASS_BATTERY,
state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
}
)
.extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA)
.extend(cv.COMPONENT_SCHEMA)
)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
await esp32_ble_tracker.register_ble_device(var, config)
cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex))
cg.add(var.set_bindkey(config[CONF_BINDKEY]))
if temperature_config := config.get(CONF_TEMPERATURE):
sens = await sensor.new_sensor(temperature_config)
cg.add(var.set_temperature(sens))
if humidity_config := config.get(CONF_HUMIDITY):
sens = await sensor.new_sensor(humidity_config)
cg.add(var.set_humidity(sens))
if battery_level_config := config.get(CONF_BATTERY_LEVEL):
sens = await sensor.new_sensor(battery_level_config)
cg.add(var.set_battery_level(sens))

View file

@ -0,0 +1,73 @@
#include "xiaomi_lywsd02mmc.h"
#include "esphome/core/log.h"
#ifdef USE_ESP32
namespace esphome {
namespace xiaomi_lywsd02mmc {
static const char *const TAG = "xiaomi_lywsd02mmc";
void XiaomiLYWSD02MMC::dump_config() {
ESP_LOGCONFIG(TAG, "Xiaomi LYWSD02MMC");
ESP_LOGCONFIG(TAG, " Bindkey: %s", format_hex_pretty(this->bindkey_, 16).c_str());
LOG_SENSOR(" ", "Temperature", this->temperature_);
LOG_SENSOR(" ", "Humidity", this->humidity_);
LOG_SENSOR(" ", "Battery Level", this->battery_level_);
}
bool XiaomiLYWSD02MMC::parse_device(const esp32_ble_tracker::ESPBTDevice &device) {
if (device.address_uint64() != this->address_) {
ESP_LOGVV(TAG, "parse_device(): unknown MAC address.");
return false;
}
ESP_LOGVV(TAG, "parse_device(): MAC address %s found.", device.address_str().c_str());
bool success = false;
for (auto &service_data : device.get_service_datas()) {
auto res = xiaomi_ble::parse_xiaomi_header(service_data);
if (!res.has_value()) {
continue;
}
if (res->is_duplicate) {
continue;
}
if (res->has_encryption &&
(!(xiaomi_ble::decrypt_xiaomi_payload(const_cast<std::vector<uint8_t> &>(service_data.data), this->bindkey_,
this->address_)))) {
continue;
}
if (!(xiaomi_ble::parse_xiaomi_message(service_data.data, *res))) {
continue;
}
if (!(xiaomi_ble::report_xiaomi_results(res, device.address_str()))) {
continue;
}
if (res->temperature.has_value() && this->temperature_ != nullptr)
this->temperature_->publish_state(*res->temperature);
if (res->humidity.has_value() && this->humidity_ != nullptr)
this->humidity_->publish_state(*res->humidity);
if (res->battery_level.has_value() && this->battery_level_ != nullptr)
this->battery_level_->publish_state(*res->battery_level);
success = true;
}
return success;
}
void XiaomiLYWSD02MMC::set_bindkey(const std::string &bindkey) {
memset(this->bindkey_, 0, 16);
if (bindkey.size() != 32) {
return;
}
char temp[3] = {0};
for (int i = 0; i < 16; i++) {
strncpy(temp, &(bindkey.c_str()[i * 2]), 2);
this->bindkey_[i] = std::strtoul(temp, nullptr, 16);
}
}
} // namespace xiaomi_lywsd02mmc
} // namespace esphome
#endif

View file

@ -0,0 +1,37 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/esp32_ble_tracker/esp32_ble_tracker.h"
#include "esphome/components/xiaomi_ble/xiaomi_ble.h"
#ifdef USE_ESP32
namespace esphome {
namespace xiaomi_lywsd02mmc {
class XiaomiLYWSD02MMC : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
public:
void set_address(uint64_t address) { this->address_ = address; }
void set_bindkey(const std::string &bindkey);
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override;
void dump_config() override;
float get_setup_priority() const override { return setup_priority::DATA; }
void set_temperature(sensor::Sensor *temperature) { this->temperature_ = temperature; }
void set_humidity(sensor::Sensor *humidity) { this->humidity_ = humidity; }
void set_battery_level(sensor::Sensor *battery_level) { this->battery_level_ = battery_level; }
protected:
uint64_t address_;
uint8_t bindkey_[16];
sensor::Sensor *temperature_{nullptr};
sensor::Sensor *humidity_{nullptr};
sensor::Sensor *battery_level_{nullptr};
};
} // namespace xiaomi_lywsd02mmc
} // namespace esphome
#endif

View file

@ -7,22 +7,22 @@ VALID_SUBSTITUTIONS_CHARACTERS = (
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
)
PLATFORM_BK72XX = "bk72xx"
PLATFORM_ESP32 = "esp32"
PLATFORM_ESP8266 = "esp8266"
PLATFORM_RP2040 = "rp2040"
PLATFORM_HOST = "host"
PLATFORM_BK72XX = "bk72xx"
PLATFORM_RTL87XX = "rtl87xx"
PLATFORM_LIBRETINY_OLDSTYLE = "libretiny"
PLATFORM_RP2040 = "rp2040"
PLATFORM_RTL87XX = "rtl87xx"
TARGET_PLATFORMS = [
PLATFORM_BK72XX,
PLATFORM_ESP32,
PLATFORM_ESP8266,
PLATFORM_RP2040,
PLATFORM_HOST,
PLATFORM_BK72XX,
PLATFORM_RTL87XX,
PLATFORM_LIBRETINY_OLDSTYLE,
PLATFORM_RP2040,
PLATFORM_RTL87XX,
]
SOURCE_FILE_EXTENSIONS = {".cpp", ".hpp", ".h", ".c", ".tcc", ".ino"}
@ -1034,8 +1034,10 @@ UNIT_KELVIN = "K"
UNIT_KILOGRAM = "kg"
UNIT_KILOMETER = "km"
UNIT_KILOMETER_PER_HOUR = "km/h"
UNIT_KILOVOLT_AMPS_REACTIVE = "kVAr"
UNIT_KILOVOLT_AMPS_REACTIVE_HOURS = "kVArh"
UNIT_KILOVOLT_AMPS = "kVA"
UNIT_KILOVOLT_AMPS_HOURS = "kVAh"
UNIT_KILOVOLT_AMPS_REACTIVE = "kVAR"
UNIT_KILOVOLT_AMPS_REACTIVE_HOURS = "kVARh"
UNIT_KILOWATT = "kW"
UNIT_KILOWATT_HOURS = "kWh"
UNIT_LUX = "lx"
@ -1066,6 +1068,7 @@ UNIT_SECOND = "s"
UNIT_STEPS = "steps"
UNIT_VOLT = "V"
UNIT_VOLT_AMPS = "VA"
UNIT_VOLT_AMPS_HOURS = "VAh"
UNIT_VOLT_AMPS_REACTIVE = "VAR"
UNIT_VOLT_AMPS_REACTIVE_HOURS = "VARh"
UNIT_WATT = "W"

134
esphome/core/bytebuffer.cpp Normal file
View file

@ -0,0 +1,134 @@
#include "bytebuffer.h"
#include <cassert>
namespace esphome {
ByteBuffer ByteBuffer::create(size_t capacity) {
std::vector<uint8_t> data(capacity);
return {data};
}
ByteBuffer ByteBuffer::wrap(uint8_t *ptr, size_t len) {
std::vector<uint8_t> data(ptr, ptr + len);
return {data};
}
ByteBuffer ByteBuffer::wrap(std::vector<uint8_t> data) { return {std::move(data)}; }
void ByteBuffer::set_limit(size_t limit) {
assert(limit <= this->get_capacity());
this->limit_ = limit;
}
void ByteBuffer::set_position(size_t position) {
assert(position <= this->get_limit());
this->position_ = position;
}
void ByteBuffer::clear() {
this->limit_ = this->get_capacity();
this->position_ = 0;
}
uint16_t ByteBuffer::get_uint16() {
assert(this->get_remaining() >= 2);
uint16_t value;
if (endianness_ == LITTLE) {
value = this->data_[this->position_++];
value |= this->data_[this->position_++] << 8;
} else {
value = this->data_[this->position_++] << 8;
value |= this->data_[this->position_++];
}
return value;
}
uint32_t ByteBuffer::get_uint32() {
assert(this->get_remaining() >= 4);
uint32_t value;
if (endianness_ == LITTLE) {
value = this->data_[this->position_++];
value |= this->data_[this->position_++] << 8;
value |= this->data_[this->position_++] << 16;
value |= this->data_[this->position_++] << 24;
} else {
value = this->data_[this->position_++] << 24;
value |= this->data_[this->position_++] << 16;
value |= this->data_[this->position_++] << 8;
value |= this->data_[this->position_++];
}
return value;
}
uint32_t ByteBuffer::get_uint24() {
assert(this->get_remaining() >= 3);
uint32_t value;
if (endianness_ == LITTLE) {
value = this->data_[this->position_++];
value |= this->data_[this->position_++] << 8;
value |= this->data_[this->position_++] << 16;
} else {
value = this->data_[this->position_++] << 16;
value |= this->data_[this->position_++] << 8;
value |= this->data_[this->position_++];
}
return value;
}
uint32_t ByteBuffer::get_int24() {
auto value = this->get_uint24();
uint32_t mask = (~(uint32_t) 0) << 23;
if ((value & mask) != 0)
value |= mask;
return value;
}
uint8_t ByteBuffer::get_uint8() {
assert(this->get_remaining() >= 1);
return this->data_[this->position_++];
}
float ByteBuffer::get_float() {
auto value = this->get_uint32();
return *(float *) &value;
}
void ByteBuffer::put_uint8(uint8_t value) {
assert(this->get_remaining() >= 1);
this->data_[this->position_++] = value;
}
void ByteBuffer::put_uint16(uint16_t value) {
assert(this->get_remaining() >= 2);
if (this->endianness_ == LITTLE) {
this->data_[this->position_++] = (uint8_t) value;
this->data_[this->position_++] = (uint8_t) (value >> 8);
} else {
this->data_[this->position_++] = (uint8_t) (value >> 8);
this->data_[this->position_++] = (uint8_t) value;
}
}
void ByteBuffer::put_uint24(uint32_t value) {
assert(this->get_remaining() >= 3);
if (this->endianness_ == LITTLE) {
this->data_[this->position_++] = (uint8_t) value;
this->data_[this->position_++] = (uint8_t) (value >> 8);
this->data_[this->position_++] = (uint8_t) (value >> 16);
} else {
this->data_[this->position_++] = (uint8_t) (value >> 16);
this->data_[this->position_++] = (uint8_t) (value >> 8);
this->data_[this->position_++] = (uint8_t) value;
}
}
void ByteBuffer::put_uint32(uint32_t value) {
assert(this->get_remaining() >= 4);
if (this->endianness_ == LITTLE) {
this->data_[this->position_++] = (uint8_t) value;
this->data_[this->position_++] = (uint8_t) (value >> 8);
this->data_[this->position_++] = (uint8_t) (value >> 16);
this->data_[this->position_++] = (uint8_t) (value >> 24);
} else {
this->data_[this->position_++] = (uint8_t) (value >> 24);
this->data_[this->position_++] = (uint8_t) (value >> 16);
this->data_[this->position_++] = (uint8_t) (value >> 8);
this->data_[this->position_++] = (uint8_t) value;
}
}
void ByteBuffer::put_float(float value) { this->put_uint32(*(uint32_t *) &value); }
void ByteBuffer::flip() {
this->limit_ = this->position_;
this->position_ = 0;
}
} // namespace esphome

96
esphome/core/bytebuffer.h Normal file
View file

@ -0,0 +1,96 @@
#pragma once
#include <utility>
#include <vector>
#include <cinttypes>
#include <cstddef>
namespace esphome {
enum Endian { LITTLE, BIG };
/**
* A class modelled on the Java ByteBuffer class. It wraps a vector of bytes and permits putting and getting
* items of various sizes, with an automatically incremented position.
*
* There are three variables maintained pointing into the buffer:
*
* 0 <= position <= limit <= capacity
*
* capacity: the maximum amount of data that can be stored
* limit: the limit of the data currently available to get or put
* position: the current insert or extract position
*
* In addition a mark can be set to the current position with mark(). A subsequent call to reset() will restore
* the position to the mark.
*
* The buffer can be marked to be little-endian (default) or big-endian. All subsequent operations will use that order.
*
*/
class ByteBuffer {
public:
/**
* Create a new Bytebuffer with the given capacity
*/
static ByteBuffer create(size_t capacity);
/**
* Wrap an existing vector in a Bytebufffer
*/
static ByteBuffer wrap(std::vector<uint8_t> data);
/**
* Wrap an existing array in a Bytebufffer
*/
static ByteBuffer wrap(uint8_t *ptr, size_t len);
// Get one byte from the buffer, increment position by 1
uint8_t get_uint8();
// Get a 16 bit unsigned value, increment by 2
uint16_t get_uint16();
// Get a 24 bit unsigned value, increment by 3
uint32_t get_uint24();
// Get a 32 bit unsigned value, increment by 4
uint32_t get_uint32();
// signed versions of the get functions
uint8_t get_int8() { return (int8_t) this->get_uint8(); };
int16_t get_int16() { return (int16_t) this->get_uint16(); }
uint32_t get_int24();
int32_t get_int32() { return (int32_t) this->get_uint32(); }
// Get a float value, increment by 4
float get_float();
// put values into the buffer, increment the position accordingly
void put_uint8(uint8_t value);
void put_uint16(uint16_t value);
void put_uint24(uint32_t value);
void put_uint32(uint32_t value);
void put_float(float value);
inline size_t get_capacity() const { return this->data_.size(); }
inline size_t get_position() const { return this->position_; }
inline size_t get_limit() const { return this->limit_; }
inline size_t get_remaining() const { return this->get_limit() - this->get_position(); }
inline Endian get_endianness() const { return this->endianness_; }
inline void mark() { this->mark_ = this->position_; }
inline void big_endian() { this->endianness_ = BIG; }
inline void little_endian() { this->endianness_ = LITTLE; }
void set_limit(size_t limit);
void set_position(size_t position);
// set position to 0, limit to capacity.
void clear();
// set limit to current position, postition to zero. Used when swapping from write to read operations.
void flip();
// retrieve a pointer to the underlying data.
uint8_t *array() { return this->data_.data(); };
void rewind() { this->position_ = 0; }
void reset() { this->position_ = this->mark_; }
protected:
ByteBuffer(std::vector<uint8_t> data) : data_(std::move(data)) { this->limit_ = this->get_capacity(); }
std::vector<uint8_t> data_;
Endian endianness_{LITTLE};
size_t position_{0};
size_t mark_{0};
size_t limit_{0};
};
} // namespace esphome

View file

@ -51,6 +51,7 @@
#define USE_MDNS
#define USE_MEDIA_PLAYER
#define USE_MQTT
#define USE_NETWORK
#define USE_NEXTION_TFT_UPLOAD
#define USE_NUMBER
#define USE_ONLINE_IMAGE_PNG_SUPPORT

View file

@ -104,7 +104,6 @@ template<typename T> class optional { // NOLINT
has_value_ = true;
}
private:
bool has_value_{false}; // NOLINT
value_type value_; // NOLINT
};

28
script/setup.bat Normal file
View file

@ -0,0 +1,28 @@
@echo off
if defined DEVCONTAINER goto :install
if defined VIRTUAL_ENV goto :install
if defined ESPHOME_NO_VENV goto :install
echo Starting the Virtual Environment
python -m venv venv
call venv/Scripts/activate
echo Running the Virtual Environment
:install
echo Installing required packages...
python.exe -m pip install --upgrade pip
pip3 install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt -r requirements_dev.txt
pip3 install setuptools wheel
pip3 install -e ".[dev,test,displays]" --config-settings editable_mode=compat
pre-commit install
python script/platformio_install_deps.py platformio.ini --libraries --tools --platforms
echo .
echo .
echo Virtual environment created. Run 'venv/Scripts/activate' to use it.

View file

@ -46,6 +46,7 @@ binary_sensor:
lvgl:
encoders:
group: switches
initial_focus: button_button
enter_button: select_button
sensor:
left_button: up_button

View file

@ -1,4 +1,5 @@
<<: !include common.yaml
packages:
device_base: !include common.yaml
web_server:
port: 8080

View file

@ -1,4 +1,5 @@
<<: !include common.yaml
packages:
device_base: !include common.yaml
web_server:
port: 8080

View file

@ -0,0 +1,12 @@
esp32_ble_tracker:
sensor:
- platform: xiaomi_lywsd02mmc
mac_address: A4:C1:38:54:5E:18
bindkey: 2529d8e0d23150a588675cc54ad48400
temperature:
name: Xiaomi LYWSD02MMC Temperature
humidity:
name: Xiaomi LYWSD02MMC Humidity
battery_level:
name: Xiaomi LYWSD02MMC Battery Level

View file

@ -0,0 +1 @@
<<: !include common.yaml

View file

@ -0,0 +1 @@
<<: !include common.yaml

View file

@ -0,0 +1 @@
<<: !include common.yaml

View file

@ -0,0 +1 @@
<<: !include common.yaml